Edit report at https://bugs.php.net/bug.php?id=39727&edit=1
ID: 39727 Comment by: charlie at rest8 dot com Reported by: edoardo at wbr dot it Summary: Commands out of sync error when calling MySQL stored procedures from PHP Status: Wont fix Type: Bug Package: MySQL related Operating System: Linux PHP Version: 4.4.4 Block user comment: N Private report: N New Comment: om,mysqli ok, why dont extend mysql_next_result for 'oriange' mysql function? Previous Comments: ------------------------------------------------------------------------ [2006-12-04 11:33:56] tony2...@php.net I'm afraid you'll have to upgrade to PHP5 in order to be able to use MySQLi, which supports this and has mysqli_next_result() method. ------------------------------------------------------------------------ [2006-12-04 11:15:45] edoardo at wbr dot it Description: ------------ >From PHP I cannot call two stored procedure in the same connection (I guess it >depends on the fact they are returning MULTI_RESULTS, it doesn't happen with >normal SELECTs) When I run the second one I get the following error: "Commands out of sync; you can't run this command now". I made a lot of tests with different MySQL versions, at the moment I'm running a 5.0.27 built from source and PHP 4.4.4 built from source and linked to 5.0.27 (not using the bundled library) and I get that error but, for example, I got it working with client libraries from MySQL 5.1.7 beta (but not with 5.1.12 beta). I already posted this bug to MySQL but they closed it telling it's not a bug (http://bugs.mysql.com/?id=24783). They pointed me at http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html but I cannot find a PHP equivalent for mysql_next_result Reproduce code: --------------- #!/usr/bin/php -q <?php define('CLIENT_MULTI_RESULTS', 131072); $conn = mysql_connect("localhost", "root", "", 1 , CLIENT_MULTI_RESULTS) or die(mysql_error()); mysql_select_db("tester") or die(mysql_error()); $query = "CALL test_proc('webrainstorm')"; for ($i = 1; $i < 5; $i++) { $ret = mysql_unbuffered_query($query) or die(mysql_error()."\n"); while ($row = mysql_fetch_array($ret, MYSQL_ASSOC)) { foreach ($row as $col) { echo "$col\t"; } echo "\n"; } mysql_free_result($ret); unset($ret); } mysql_close($conn); ?> Find SQL test script at http://www.webrainstorm.it/tmp/test.sql Expected result: ---------------- # ./test.php enabled enabled enabled enabled Actual result: -------------- # ./test.php enabled Commands out of sync; you can't run this command now ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=39727&edit=1