Solved

php problems calling stored mysql procudure

Posted on 2011-02-14
5
358 Views
Last Modified: 2012-08-13
Hi Experts,

I have the following code in PHP:
$mysql = mysql_connect("localhost","myuser","password",false,65536);
mysql_select_db("mydb", $mysql);
$sql = "CALL UPDATE_LINE_ITEMS(123)";
$rs = mysql_query( $sql )
or  
die (mysql_errno());
mysql_close($mysql);

Open in new window


Re mysql, 'myuser' has execute privileges on this procedure - ie if I call this through the mysql console it works.  However, when I call this procedure using php it sometimes works and sometimes doesn't. How do I debug (using php) why this isn't being called?

Thanks
0
Comment
Question by:jagku
  • 2
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 500 total points
ID: 34887830
You need to echo the errno. Though an intermittent problem may mean a dodgy connection is timing out.

if (!mysql_query( $sql ))
     echo mysql_errno();
0
 

Expert Comment

by:mansoflaco
ID: 34887835
Hi!
Did you get any error code (tru mysql_errno)? Or simply the mysql_query function isn't being called?
Try inserting and ECHO (echo "Line 3:" . $sql;) between lines 3 and 4 to see if that section of code has been reached.
0
 

Author Comment

by:jagku
ID: 34887893
Hi,

Thanks. I get error 1312.
My procedure doesn't return anything.
Any ideas how I can overcome this?

I thought the 65536 parameter should have fixed this - but it hasn't.

Thanks
0
 
LVL 17

Expert Comment

by:Chris Harte
ID: 34887977
Try using mysqli, this is an improved interface and should work.

http://uk.php.net/manual/en/mysqli.connect.php
0
 

Author Closing Comment

by:jagku
ID: 34888023
Thanks.
I think the problem was that I had a select in the stored procedure that I was using for debugging - which was probably baffling the php-mysql API.
I have commented this out and it seems to be working.

Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question