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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.