Skip to content
Advertisement

Php -MySQL query failing – error Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean

I have following php code :

JavaScript

I get the generic error but when I run the same code on MySQL then it works without error. Can someone please help me what am I missing .

I even tried exception handling but it didn’t help.

NOTE : code fails in the while loop condition.

Advertisement

Answer

The mysqli_multi_query() executes one or multiple queries which are concatenated by a semicolon.To retrieve the resultset from the first query you can use mysqli_use_result() or mysqli_store_result(). All subsequent query results can be processed using mysqli_more_results() and mysqli_next_result().mysqli_multi_query() only returns FALSE if the first statement failed. To retrieve subsequent errors from other statements you have to call mysqli_next_result() first.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement