php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39727 Commands out of sync error when calling MySQL stored procedures from PHP
Submitted: 2006-12-04 11:15 UTC Modified: 2006-12-04 11:33 UTC
Votes:25
Avg. Score:4.1 ± 1.2
Reproduced:19 of 20 (95.0%)
Same Version:5 (26.3%)
Same OS:9 (47.4%)
From: edoardo at wbr dot it Assigned:
Status: Wont fix Package: MySQL related
PHP Version: 4.4.4 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-12-04 11:15 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-04 11:33 UTC] tony2001@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.
 [2012-07-19 04:12 UTC] charlie at rest8 dot com
om,mysqli ok, why dont extend mysql_next_result for 'oriange' mysql function?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC