Connecting Tech Pros Worldwide Help | Site Map

call MySQL stored procedure from php

Urmi Biswas
Guest
 
Posts: n/a
#1: Nov 19 '08
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


Jerry Stuckle
Guest
 
Posts: n/a
#2: Nov 19 '08

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
==================
Urmi Biswas
Guest
 
Posts: n/a
#3: Nov 19 '08

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
==================

Jerry Stuckle
Guest
 
Posts: n/a
#4: Nov 19 '08

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
==================
Jerry Stuckle
Guest
 
Posts: n/a
#5: Nov 20 '08

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
==================
Urmi Biswas
Guest
 
Posts: n/a
#6: Nov 20 '08

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