Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php problems calling stored mysql procudure

Posted on 2011-02-14
5
Medium Priority
?
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
Chris Harte earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

705 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