Mysqli_fetch_all wont work (PHP/mysql)


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


What does your code do?


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.


Is this what you are reffering to?


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.


I’ll check your code and reply with the results.


Try now, is that what you were looking for?
If it did solve your issue, please click on that green tick to mark this topic as solved :wink:


The whole table. Like I said it seems a bit counterintuitive, but I just want to output the whole table.


Let me have a look at it…


like I said, the fetch worked for me a while back, but after I inputted the variables and messed with some things, its now giving me an error


What about now? :wink:


yes! thank you!


You can have a look at this tutorial if you want to know how I solved the problem :slight_smile:


Black Friday Sale 90% OFF