my 1st day with stored procedures.
when i call the procedure for the 2nd time i get an error?
it seems it has something to do with the way i fetch the result and i have to free the result?
I have tried different ways, but i can’t get it error-free:(
$t = 27;
$res = $mysqli->query("CALL ts_open_uitdagingen('".$t."')");
$aRes = $res->fetch_assoc();
echo '<br />'.$aRes['open_uitdagingen'].'<br />';
echo'<hr />';
$t = 80;
$res = $mysqli->query("CALL ts_open_uitdagingen('".$t."')");
echo "<br />CALL failed?: (" . $mysqli->errno . ") " . $mysqli->error;
$aRes = $res->fetch_assoc();
echo 'bBr />'.$aRes['open_uitdagingen'].'<br />';
echo'<hr />';
Displays:
1
CALL failed?: (2014) Commands out of sync; you can’t run this command now Fatal error: Call to a member function fetch_assoc() on a non-object in /home/xxxxxxxxxx.nl/public_html/content/speler_uitdagen.php on line 14
I admit I never used
mysqliin this way, but from this comment it seems that you need to use both$res->close()and$mysqli->next_result()before calling the SP again: