fooDigi Posted October 25, 2007 Share Posted October 25, 2007 when i try and run multiple stored procedures, the second mysqli_query call fails, and i get the following error. here is the error: Commands out of sync; you can't run this command now here is my code: if($result = mysqli_query($link, "call spSelectProductData(1888);")){ $pa = mysqli_fetch_array($result); print_r($pa); }else{ echo mysqli_error($link); } if($result = mysqli_query($link, "select * from tblProducts")){ $pa = mysqli_fetch_array($result); print_r($pa); }else{ echo mysqli_error($link); } Link to comment https://forums.phpfreaks.com/topic/74783-php-mysql-stored-procedures/ Share on other sites More sharing options...
effigy Posted October 25, 2007 Share Posted October 25, 2007 Does this help? Link to comment https://forums.phpfreaks.com/topic/74783-php-mysql-stored-procedures/#findComment-378108 Share on other sites More sharing options...
fooDigi Posted October 25, 2007 Author Share Posted October 25, 2007 i have looked at that, i guess i would like to see a working example of how to use it, but can't find one. Link to comment https://forums.phpfreaks.com/topic/74783-php-mysql-stored-procedures/#findComment-378122 Share on other sites More sharing options...
fooDigi Posted October 25, 2007 Author Share Posted October 25, 2007 well, i got the results i needed. it seems very awkward to do it this way, but it works. i have read that you have to use mysql_multi_query if you plan to make more than one stored procedure call in a script. is this true? anyway, here is how i got it to work. $query = "call spSelectProductData(1888);"; $query .= "call spSelectProductData(1889);"; /* execute multi query */ if (mysqli_multi_query($link, $query)) { /* store first result set */ if ($result = mysqli_store_result($link)) { $pa = mysqli_fetch_array($result); print_r($pa); mysqli_free_result($result); } /* have to do it twice for some reason */ mysqli_next_result($link); mysqli_next_result($link); /* store second result set */ if ($result = mysqli_store_result($link)) { $pa = mysqli_fetch_array($result); print_r($pa); mysqli_free_result($result); } } /* close connection */ mysqli_close($link); Link to comment https://forums.phpfreaks.com/topic/74783-php-mysql-stored-procedures/#findComment-378148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.