Quantcast
Channel: User spraff - Stack Overflow
Viewing all articles
Browse latest Browse all 56

MySQL "commands out of sync" appears when migrating to stored procedures

$
0
0

I have some working php/mysql which I am now migrating to stored procedures.

As soon as any stored procedure is called, subsequent CALLs and SELECTs fail with "Commands out of sync; you can't run this command now".

Existing stored procedures which are not SELECTs work fine.

function db_all ($query){    log_sql_read ($query);    $result = mysql_query ($query, db_connection ());    if (!$result)    {        log_sql_error ($query);        return Array ();    }    $rows = Array ();    while ($row = mysql_fetch_assoc ($result))        array_push ($rows, $row);    mysql_free_result ($result);    return $rows;}db_all ("SELECT 1 as `test`");db_all ("SELECT 2 as `test`");db_all ("CALL `$db`.`select_info`($id);"); // RETURNS CORRECT DATAdb_all ("CALL `$db`.`select_info`($id);"); // ERROR HEREdb_all ("SELECT 5 as `test`");             // ERROR HERE

This error is explained elsewhere as a result of not calling mysql_free_result, but I do call this. So what's wrong?

I'm seeing some solutions which refer to mysqli. I need a non-mysqli solution for now.


Viewing all articles
Browse latest Browse all 56

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>