pandyboy Posted April 8, 2008 Share Posted April 8, 2008 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. Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/ Share on other sites More sharing options...
craygo Posted April 8, 2008 Share Posted April 8, 2008 why are you using $insert->fetch_array() I do not see you calling an object called $insert. Looking at what you have for code shouldn't it be $mysqli->fetch_array() and $mysqli->free_result() Ray Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/#findComment-511957 Share on other sites More sharing options...
pandyboy Posted April 8, 2008 Author Share Posted April 8, 2008 No, the code is correct and works. Both queries work fine on their own, it's only when I run one after the other that I have a problem. Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/#findComment-511991 Share on other sites More sharing options...
pandyboy Posted April 9, 2008 Author Share Posted April 9, 2008 I still have no fix for this. Is there really nobody out there who uses MySQL stored procedures and OO style mysqli? Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/#findComment-512754 Share on other sites More sharing options...
craygo Posted April 9, 2008 Share Posted April 9, 2008 nothing like google and php.net!! http://us2.php.net/manual/en/function.mysqli-next-result.php Ray Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/#findComment-512891 Share on other sites More sharing options...
pandyboy Posted April 9, 2008 Author Share Posted April 9, 2008 Tried that - it didn't work. That's only necessary if you're running it within a multi query, which I'm not. As I said, it only fails when using the OO style structure, not the procedural style. Link to comment https://forums.phpfreaks.com/topic/100131-problem-calling-one-stored-procedure-after-another/#findComment-512896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.