call MySQL stored procedure from php 
November 19th, 2008, 05:25 PM
| | | |
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 | 
November 19th, 2008, 08:45 PM
| | | | 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
================== | 
November 19th, 2008, 09:25 PM
| | | | 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
==================
| | 
November 19th, 2008, 10:35 PM
| | | | 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
================== | 
November 20th, 2008, 12:55 PM
| | | | 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
================== | 
November 20th, 2008, 05:25 PM
| | | | 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 |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|