tmatt95 Posted January 2, 2009 Share Posted January 2, 2009 Hi I am writing a php script for for my website to access a database. I can run one stored procedure alright, however when I try and run two the second does not want to run. I inserted some debugging code and it prints "failed 2" onto the screen even though the sql code will run in the mysql query browser. Below is the code I am trying to get to work: $dblatestimage2 ="CALL bw_ProfileGetLatestUploadedImage(1)"; /*calls random image */ $latestimage2 = $db->query($dblatestimage2); if ($latestimage2 == FALSE) { print "failed1"; exit; } $row2 = $latestimage2->fetch_assoc(); $dblatestimage3 ="CALL bw_ProfileUserIDGet('administrator')"; /*calls random image */ $latestimage3 = $db->query($dblatestimage3); if ($latestimage3 == FALSE) { print "failed2"; exit; } $row3 = $latestimage3->fetch_assoc(); Can anyone help remove the error. Thanks, Matt Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/ Share on other sites More sharing options...
Mchl Posted January 2, 2009 Share Posted January 2, 2009 try echoing $db->error; instead of print "failed2"; Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728239 Share on other sites More sharing options...
tmatt95 Posted January 2, 2009 Author Share Posted January 2, 2009 Thanks for the help. I changed the code as you suggested and now get this error message: Commands out of sync; you can't run this command now . Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728265 Share on other sites More sharing options...
Mchl Posted January 2, 2009 Share Posted January 2, 2009 http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728268 Share on other sites More sharing options...
tmatt95 Posted January 2, 2009 Author Share Posted January 2, 2009 http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html Thanks for the link. How would I implement that into the php code above (have looked on google and im my php book and cannot get it working)? Thanks, Matt Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728317 Share on other sites More sharing options...
Mchl Posted January 2, 2009 Share Posted January 2, 2009 Sorry, but I have no idea Never got into stored procedures too much, and never had this particular problem. Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728320 Share on other sites More sharing options...
tmatt95 Posted January 2, 2009 Author Share Posted January 2, 2009 Sorry, but I have no idea Never got into stored procedures too much, and never had this particular problem. Thanks for your help. I got a book for Christmas on stored procedures and they only have examples in which one is run . Out of interest how do you code your database code in php? Regards, Matt Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728324 Share on other sites More sharing options...
Mchl Posted January 2, 2009 Share Posted January 2, 2009 Depends on what I want to achieve... I usually have a separate class that creates a database connection as a singleton, and then separate classes for each database object (like users, messages) with static methods that take care of INSERTs UPDATEs etc... (those should be moved to namespaces, once PHP 5.3 is out) Link to comment https://forums.phpfreaks.com/topic/139226-sending-more-than-one-stored-procedure/#findComment-728333 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.