• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

php problems calling stored mysql procudure

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
jagku
Asked:
jagku
  • 2
  • 2
1 Solution
 
Chris HarteThaumaturgeCommented:
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
 
mansoflacoCommented:
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
 
jagkuAuthor Commented:
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
 
Chris HarteThaumaturgeCommented:
Try using mysqli, this is an improved interface and should work.

http://uk.php.net/manual/en/mysqli.connect.php
0
 
jagkuAuthor Commented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now