PHP commands due to synchronization error

This simple code calls two MySQL procedures, but after the first one that returns values, it returns an error in the second query.

NOTE. The launch of the first or second one will correctly return for each of them. So the queries work, just not together.

Full error: Invalid query: Commands out of sync; you can't run this command now Invalid query: Commands out of sync; you can't run this command now

Any ideas please.

 <?php require_once ('connection.php'); //First Query and Output $result = mysql_query("CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');"); if (!$result) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_array($result)) { echo $row['CommisionPercentage']; } mysql_free_result($result); //END First Query and Output //Second Query and Output $new2 = mysql_query("CALL C01_Client_Summary_ByBetType(1, '2012-02-27', '2013-03-29');"); if (!$new2) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_array($new2)) { echo $row['Turnover']; } //END Second Query and Output ?> 
+7
source share
1 answer

The old MySQL extension for PHP does not work properly with stored procedures. Unfortunately, seams cannot perform multiple stored procedures with it. The problem is that the first procedure leaves some buffer result set, because of which the second can fail. However, you can use the mysqli extension. Here is a good example of how to do this:

http://www.daniweb.com/web-development/php/threads/234868/error-commands-out-of-sync-you-cant-run-this-command-now

+5
source

All Articles