mysql - Why is my PHP code not properly query-ing the database? -
mysql - Why is my PHP code not properly query-ing the database? -
the problem lies in perform query lines of code. i'm trying insert 2 strings column in database. i'm not getting error, it's not working. furthermore, if alter "checked boxes" column name random string, don't error, suggests code not connecting database properly? end goal set values of $_post["nutrient"] column in database. thanks.
<?php if(isset($_post["submit"])){ print_r ($_post["nutrient"]); } session_start(); //establish connection $server = "localhost"; $db_username = "root"; $db_password = ""; $database = "gainlife_cavin"; $table = "cavintable"; //connect php script database $connection = mysqli_connect("$server","$db_username","$db_password","$database"); //check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } //perform query mysqli_query($connection,"select * $table"); mysqli_query($connection,"insert $table(checked boxes) values ('glenn','quagmire')") //mysqli_close($connection); ?>
first of all, don't check homecoming codes. without this, cannot sure if there error or not.
the reason failing insert might missing comma between column names. when alter insert statement
insert $table(checked, boxes) values ('glenn','quagmire') it should work, provided column names correct, of course.
php mysql sql
Comments
Post a Comment