Connecting Tech Pros Worldwide Help | Site Map

call MySQL stored procedure from php

  #1  
Old November 19th, 2008, 05:25 PM
Urmi Biswas
Guest
 
Posts: n/a
Hi All,

Has anyone tried calling MySQL stored procedure from php scripts?
I use PEAR DB module to access MySQL database.
Not sure if php 4.4.0 (that we use) support calling stored procedures.

Regards,
Urmi


  #2  
Old November 19th, 2008, 08:45 PM
Jerry Stuckle
Guest
 
Posts: n/a

re: call MySQL stored procedure from php


Urmi Biswas wrote:
Quote:
Hi All,
>
Has anyone tried calling MySQL stored procedure from php scripts?
I use PEAR DB module to access MySQL database.
Not sure if php 4.4.0 (that we use) support calling stored procedures.
>
Regards,
Urmi
>
>
I know of no reason why php 4.x (it's now backlevel and no longer
supported - you should update ASAP) shouldn't support it, but php 5.x
supports it fine.

Did you try it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #3  
Old November 19th, 2008, 09:25 PM
Urmi Biswas
Guest
 
Posts: n/a

re: call MySQL stored procedure from php


Thanks Jerry for replying.

I tried the following:

$sth=$db->prepare("call validateFBT(?,?)");
$bindvars=array("1" =$SelectedFBT,"2" =$frequency);
$res=$db->execute($sth,$bindvars);

if (DB::iserror($res)) {
die($res ->getMessage( ));
}

I get 'DB Error: unknown error'.

Regards,
Urmi






"Jerry Stuckle" <jstucklex@attglobal.netwrote in message
news:gg1th3$5dc$2@news.motzarella.org...
Quote:
Urmi Biswas wrote:
Quote:
>Hi All,
>>
>Has anyone tried calling MySQL stored procedure from php scripts?
>I use PEAR DB module to access MySQL database.
>Not sure if php 4.4.0 (that we use) support calling stored procedures.
>>
>Regards,
>Urmi
>>
>>
>
I know of no reason why php 4.x (it's now backlevel and no longer
supported - you should update ASAP) shouldn't support it, but php 5.x
supports it fine.
>
Did you try it?
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

  #4  
Old November 19th, 2008, 10:35 PM
Jerry Stuckle
Guest
 
Posts: n/a

re: call MySQL stored procedure from php


Urmi Biswas wrote:
Quote:
"Jerry Stuckle" <jstucklex@attglobal.netwrote in message
news:gg1th3$5dc$2@news.motzarella.org...
Quote:
>Urmi Biswas wrote:
Quote:
>>Hi All,
>>>
>>Has anyone tried calling MySQL stored procedure from php scripts?
>>I use PEAR DB module to access MySQL database.
>>Not sure if php 4.4.0 (that we use) support calling stored procedures.
>>>
>>Regards,
>>Urmi
>>>
>>>
>I know of no reason why php 4.x (it's now backlevel and no longer
>supported - you should update ASAP) shouldn't support it, but php 5.x
>supports it fine.
>>
>Did you try it?
>>
Thanks Jerry for replying.
>
I tried the following:
>
$sth=$db->prepare("call validateFBT(?,?)");
$bindvars=array("1" =$SelectedFBT,"2" =$frequency);
$res=$db->execute($sth,$bindvars);
>
if (DB::iserror($res)) {
die($res ->getMessage( ));
}
>
I get 'DB Error: unknown error'.
>
Regards,
Urmi
>
(Top posting fixed)

That may be because you're trying to use prepared statements. Not sure
though. Do other operations work OK? Can you call your SP via
mysql_query()?

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #5  
Old November 20th, 2008, 12:55 PM
Jerry Stuckle
Guest
 
Posts: n/a

re: call MySQL stored procedure from php


Álvaro G. Vicario wrote:
Quote:
Urmi Biswas escribió:
Quote:
>$sth=$db->prepare("call validateFBT(?,?)");
>$bindvars=array("1" =$SelectedFBT,"2" =$frequency);
>$res=$db->execute($sth,$bindvars);
>>
> if (DB::iserror($res)) {
> die($res ->getMessage( ));
> }
>>
>I get 'DB Error: unknown error'.
>
According to the example in docs execute() seems to expect a numeric
zero-based array:
>
http://pear.php.net/manual/en/packag...on.execute.php
>
Check whether you get the same error if you don't specify array indexes
(which are not needed anyway).
>
Good catch, Álvaro. That one went right by me.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #6  
Old November 20th, 2008, 05:25 PM
Urmi Biswas
Guest
 
Posts: n/a

re: call MySQL stored procedure from php


"Jerry Stuckle" <jstucklex@attglobal.netwrote in message
news:gg3mmp$ke$3@news.motzarella.org...
Quote:
Álvaro G. Vicario wrote:
Quote:
>Urmi Biswas escribió:
Quote:
>>$sth=$db->prepare("call validateFBT(?,?)");
>>$bindvars=array("1" =$SelectedFBT,"2" =$frequency);
>>$res=$db->execute($sth,$bindvars);
>>>
>> if (DB::iserror($res)) {
>> die($res ->getMessage( ));
>> }
>>>
>>I get 'DB Error: unknown error'.
>>
>According to the example in docs execute() seems to expect a numeric
>zero-based array:
>>
>http://pear.php.net/manual/en/packag...on.execute.php
>>
>Check whether you get the same error if you don't specify array indexes
>(which are not needed anyway).
>>
>
Good catch, Álvaro. That one went right by me.
>
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Tried without array index.... doesn't work. Same error.
mysqli comes with php 5.

Tried using mysql_query, it works!!!

Thanks to all, for your inputs.

Regards,
Urmi


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a MS SQL Server stored-procedure from PHP? rinal86 answers 4 October 2nd, 2008 12:48 AM
how to call mysql stored procedure from php sbettadpur answers 1 March 29th, 2008 04:07 PM
mysql vs. mysqli, how to call stored procedure from php eholz1 answers 1 February 27th, 2007 11:15 PM
PHP and MySQL: How to Properly call a Stored Procedure with Output Parameters from PHP - mysql, mysqli, or PDO IamtheEvster answers 0 April 10th, 2006 04:35 PM