'2nd call to stored procedure gives error (2014) [duplicate]

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source