Jump to content

Problem calling one stored procedure after another


pandyboy

Recommended Posts

I am tearing my hair out over this:

 

<?php
$mysqli = new mysqli("localhost", "username", "password", "database");

$query1="CALL procedure1 (1)";
$insert=$mysqli->query($query1);
$row = $insert->fetch_array();
print_r($row);
$insert->free_result();

$query2="CALL procedure2 (1,2,3)";
if (!$mysqli->query($query2)) {
printf("Error: %s\n", $mysqli->error ."<br />");
}
$mysqli->close();
?>

 

It refuses to run the second SP giving me a "Commands out of sync; you can't run this command now" error, despite me using the "$insert->free_result();" on the first one.

 

If I do the same as above but use procedural instead of OO style, it works fine. I don't wish to use procedural style, as I am using this within a class.

 

I can't use the mysqli_multi_query as the second procedure relies on the information returned by the first.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.