Solved

php problems calling stored mysql procudure

Posted on 2011-02-14
5
357 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SubQuery link 4 35
What does this formatting equate to? 7 18
Use Select Query to Return Results as a Form 9 23
Formating field inside mysql query 2 13
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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