Hi fellows,
I have problem in php code and I had searched in days but I didn't found something good.
The problem is when execute the following code and error occured:

$sql = "CALL categoriesSelectByParent($CategId)";
if(!($result = $con->query($sql)))
    echo "Failed: (" . $con->errno . ") " . $con->error;
else {
//Do something with the result.


$sql = "CALL booksSelectByCategoryId($CategId)";
if(!($result = $con->query($sql)))
    echo "Failed: (" . $con->errno . ") " . $con->error;
else {
//Do something with the result.

the error is:

"Failed: (2014) Commands out of sync; you can't run this command now"

I know the error because of the second call. But how can I solve this.

I hope somebody have the solution.

Recommended Answers

All 6 Replies

try adding under line 8:


Because you are not flushing the content

or use


Squidge, the problem still.

pritaeas, none of those solution in this thread help.

It's hard to guess, you don't even mention if you are using MySQLi, or something else.

I had solved by these two lines:



I replace it with $result->free();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.