My data enters fine into my database with this code, but I can’t seem to be able to use the mysqli_fetch_all function correctly. It worked before, but after tweeking and cutting out previous code, and playing around with it, it gave me a warning: Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, boolean given.
Any ideas on how I can tweak my code to fix this problem?
//-----------------------------------------------------------------------------------
$ID = $_GET["ID"];
$Name = $_GET["Name"];
$Address = $_GET["Address"];
//-----------------------------------------------------------------------------------
$sql = "INSERT INTO people (ID, Name, Address) VALUES ('$ID', '$Name', '$Address')";
$query = mysqli_query($connection,$sql);
//-----------------------------------------------------------------------------------
$rows = mysqli_fetch_all($query); // convert result to array
print_r($rows); // print result
//-----------------------------------------------------------------------------------
mysqli_close($connection); //disconnects $connection from MySQL server
?>
Connects to MySQL and puts user inputted data into a table. This part works.
I just want to have the tables data be sent back to be printed out on screen. It worked before, but I altered my code a little bit and now its giving me a warning. Before I hardcoded values into the “INSERT INTO” sql line, but I changed them to variables for user input. This change might have been the problem, but I also cleaned up my code and deleted other lines I didn’t think I needed. This might be giving me the warning.
Sorry, I don’t have tons of PHP/MYSQL experience.
Yeah, the user enters in values, and I used the $_GET[ ] line to save them as variables. This works properly though. Users can enter data and it is stored inside the database. My problem is having the database table print back out so the user can see. The form and data entry all seems to be working fine.