#22 2014: Commands out of sync; you can't run this command now

open
nobody
None
5
2014-08-17
2007-07-29
Anonymous
No

When calling more then one query after calling a stored procedure in php5 using the mysqli driver, mysql/adodb returns the following error:

2014: Commands out of sync; you can't run this command now

Fix:

Add a line to the function _query in the file: adodb_mysqli.inc.php

// returns queryID or false
function _query($sql, $inputarr)
{
global $ADODB_COUNTRECS;

if (is_array($sql)) {
$stmt = $sql[1];
$a = '';
foreach($inputarr as $k => $v) {
if (is_string($v)) $a .= 's';
else if (is_integer($v)) $a .= 'i';
else $a .= 'd';
}

$fnarr = array_merge( array($stmt,$a) , $inputarr);
$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);

$ret = mysqli_stmt_execute($stmt);
return $ret;
}
if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
return false;
}

// Begin fix error: 2014
mysqli_next_result($this->_connectionID);
// End fix error: 2014

return $mysql_res;
}

See php.net for more info:

http://nl2.php.net/manual/nl/function.mysqli-next-result.php

Discussion