Mysqli_fetch_all wont work (PHP/mysql)


#1

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
?>

#2

What does your code do?


#3

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.


#4

Is this what you are reffering to?


#5

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.


#6

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


#10

Try now, is that what you were looking for?
https://logansnebula.000webhostapp.com/db_form.html
If it did solve your issue, please click on that green tick to mark this topic as solved :wink:


#11

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


#12

Let me have a look at it…


#13

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


#14

What about now? :wink:


#15

yes! thank you!


#17

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


#18

Black Friday Sale 90% OFF
0
DAYS
0
HOURS
0
MINUTES
0
SECONDS
×