0

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.
}

$result->free();

$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.

3
Contributors
6
Replies
18
Views
4 Years
Discussion Span
Last Post by Rasool Ahmed
0

try adding under line 8:

$sql->free();

Because you are not flushing the content

or use

unset($sql);

Edited by Squidge

0

I had solved by these two lines:

        mysqli_free_result($result);

        mysqli_next_result($con);

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.