PHP 4.3 - Running stored procedures

Reply

Join Date: Jul 2008
Posts: 2
Reputation: zicomerc is an unknown quantity at this point 
Solved Threads: 0
zicomerc zicomerc is offline Offline
Newbie Poster

PHP 4.3 - Running stored procedures

 
0
  #1
Jul 16th, 2008
Hi,

I've just discovered mysql stored procedures and have been using PHP4 a few years now, but not as my day job. I can get a mysql stored procedure to execute and work in the PHP script, but I'm having problems executing multiple stored procedures. Each of them returns one recordset.

My connection string looks like this:

mysql_connect(hostname,dbname,password,TRUE, 131072);
A sample of my code that produces the error looks like this:

  1. include('connection.php');
  2.  
  3. $sql = "CALL PlayerListPosition (2, 3, 4);";
  4.  
  5. $result = mysql_query($sql);
  6.  
  7. while ($rowresult = mysql_fetch_row($result))
  8. {
  9. echo "$rowresult[0] <BR />";
  10. }
  11.  
  12. $sql = "CALL PlayerListPosition (2, 1, 1);";
  13.  
  14. $result = mysql_query($sql);
  15.  
  16. while ($rowresult = mysql_fetch_row($result))
  17. {
  18. echo "$rowresult[0] <BR />";
  19. }

Now the first recordset works just fine, but when its time to run the second recordset I get a mysql_fetch_row error as below.

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource
If I executed the second procedure on its own that works too.

Do I need to close the recordset before using the next one? How would I do this? I've tried running multiple in line sql SELECT statements and I dont get a problem - its only when I use multiple stored procedures in a page - that this error occurs.

I really would like to start using stored procedures now that I've discovered them so any help in getting around this problem would be great! Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2
Reputation: zicomerc is an unknown quantity at this point 
Solved Threads: 0
zicomerc zicomerc is offline Offline
Newbie Poster

Re: PHP 4.3 - Running stored procedures

 
0
  #2
Jul 16th, 2008
Can anyone help? Surely someone must know how to run 2 stored procedures on a single PHP page?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC