Cant get Mysql stored procedure to work.
Cant get Mysql stored procedure to work.
am 13.07.2009 17:52:34 von Patrick Moloney
I've had no success trying to execute any stored procedure from php.
I'm just trying to follow the example for multi-query in the php manual,
and have tried an example from Artfulsoftware.com. I have one input and
one output parameter. I've simplified the stored procedure to always
output one value from one record, regardless of the value passed in.
The SP works in Mysql. Just cant run it from php. It returns False.
I look at the query log in mysql and it calls the stored procedure, and
shows the input value and output variable. No further information. I'm
not familiar with that log so I don't know what it should look like.
The only thing I see looks like a brief reference to UTC8 - but I don't
think I am (intentionally) using that anywhere. I get no other error
back or logged. I'm using root as the user, which is the only defined
user. Should this work, or are stored procedures not working well?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 13.07.2009 19:18:22 von Phpster
On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney wrote:
> I've had no success trying to execute any stored procedure from php.
> I'm just trying to follow the example for multi-query in the php manual, and
> have tried an example from Artfulsoftware.com. I have one input and one
> output parameter. I've simplified the stored procedure to always output one
> value from one record, regardless of the value passed in.
> The SP works in Mysql. Just cant run it from php. It returns False.
> I look at the query log in mysql and it calls the stored procedure, and
> shows the input value and output variable. No further information. I'm not
> familiar with that log so I don't know what it should look like.
> The only thing I see looks like a brief reference to UTC8 - but I don't
> think I am (intentionally) using that anywhere. I get no other error back or
> logged. I'm using root as the user, which is the only defined user. Should
> this work, or are stored procedures not working well?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Can you show the php code?
--
Bastien
Cat, the other other white meat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 13.07.2009 19:33:13 von Patrick Moloney
Bastien Koert wrote:
> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney wrote:
>> I've had no success trying to execute any stored procedure from php.
>> I'm just trying to follow the example for multi-query in the php manual, and
>> have tried an example from Artfulsoftware.com. I have one input and one
>> output parameter. I've simplified the stored procedure to always output one
>> value from one record, regardless of the value passed in.
>> The SP works in Mysql. Just cant run it from php. It returns False.
>> I look at the query log in mysql and it calls the stored procedure, and
>> shows the input value and output variable. No further information. I'm not
>> familiar with that log so I don't know what it should look like.
>> The only thing I see looks like a brief reference to UTC8 - but I don't
>> think I am (intentionally) using that anywhere. I get no other error back or
>> logged. I'm using root as the user, which is the only defined user. Should
>> this work, or are stored procedures not working well?
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Can you show the php code?
>
Below is the relevant code. The database connection is established, but
the query call returns False. The call is recorded in the mysql query
log. No error there or returned, but just False. Proc works in mysql and
ignores the value of the input parameter and returns 1 string. But I
can't get it to do that from php.
@$db = new mysqli('localhost', 'root', 'password', 'Sales');
if (mysqli_connect_errno())
{ echo 'Error: could not connect to database. ';
exit;
}
$brandrequest = 'x';
$res = $db->multi_query( "CALL myproc($brandrequest, ModelID); " );
if (!$res ) {
echo 'No Listings were found for this request.';
echo mysql_error();
exit;
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 13.07.2009 19:40:21 von Phpster
On Mon, Jul 13, 2009 at 1:33 PM, Patrick Moloney wrote:
> Bastien Koert wrote:
>>
>> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney
>> wrote:
>>>
>>> I've had no success trying to execute any stored procedure from php.
>>> I'm just trying to follow the example for multi-query in the php manual=
,
>>> and
>>> have tried an example from Artfulsoftware.com. I have one input and one
>>> output parameter. I've simplified the stored procedure to always output
>>> one
>>> value from one record, regardless of the value passed in.
>>> The SP works in Mysql. Just cant run it from php. It returns False.
>>> I look at the query log in mysql and it calls the stored procedure, and
>>> shows the input value and output variable. No further information. I'm
>>> not
>>> familiar with that log so I don't know what it should look like.
>>> The only thing I see looks like a brief reference to UTC8 - but I don't
>>> think I am (intentionally) using that anywhere. I get no other error ba=
ck
>>> or
>>> logged. I'm using root as the user, which is the only defined user.
>>> Should
>>> this work, or are stored procedures not working well?
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Can you show the php code?
>>
>
> Below is the relevant code. The database connection is established, but t=
he
> query call returns False. The call is recorded in the mysql query log. No
> error there or returned, but just False. Proc works in mysql and =A0ignor=
es
> the value of the input parameter and returns 1 string. But I can't get it=
to
> do that from php.
>
>
> =A0 =A0@$db =3D new mysqli('localhost', 'root', 'password', 'Sales');
> =A0 =A0if (mysqli_connect_errno())
> =A0 =A0{ echo 'Error: could not connect to database. ';
> =A0 =A0 =A0exit;
> =A0 =A0}
>
> =A0 =A0$brandrequest =3D 'x';
> =A0 =A0$res =3D $db->multi_query( "CALL myproc($brandrequest, ModelID); "=
=A0);
> =A0 =A0if (!$res ) {
> =A0 =A0 =A0echo 'No Listings were found for this request.';
> =A0 =A0 =A0echo mysql_error();
> =A0 =A0 =A0exit;
> =A0 =A0}
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Is the multi_query call the correct one?
--=20
Bastien
Cat, the other other white meat
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 13.07.2009 19:49:30 von Patrick Moloney
Bastien Koert wrote:
> On Mon, Jul 13, 2009 at 1:33 PM, Patrick Moloney wrote:
>> Bastien Koert wrote:
>>> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney
>>> wrote:
>>>> I've had no success trying to execute any stored procedure from php.
>>>> I'm just trying to follow the example for multi-query in the php manual,
>>>> and
>>>> have tried an example from Artfulsoftware.com. I have one input and one
>>>> output parameter. I've simplified the stored procedure to always output
>>>> one
>>>> value from one record, regardless of the value passed in.
>>>> The SP works in Mysql. Just cant run it from php. It returns False.
>>>> I look at the query log in mysql and it calls the stored procedure, and
>>>> shows the input value and output variable. No further information. I'm
>>>> not
>>>> familiar with that log so I don't know what it should look like.
>>>> The only thing I see looks like a brief reference to UTC8 - but I don't
>>>> think I am (intentionally) using that anywhere. I get no other error back
>>>> or
>>>> logged. I'm using root as the user, which is the only defined user.
>>>> Should
>>>> this work, or are stored procedures not working well?
>>>>
>>>> --
>>>> PHP Database Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> Can you show the php code?
>>>
>> Below is the relevant code. The database connection is established, but the
>> query call returns False. The call is recorded in the mysql query log. No
>> error there or returned, but just False. Proc works in mysql and ignores
>> the value of the input parameter and returns 1 string. But I can't get it to
>> do that from php.
>>
>>
>> @$db = new mysqli('localhost', 'root', 'password', 'Sales');
>> if (mysqli_connect_errno())
>> { echo 'Error: could not connect to database. ';
>> exit;
>> }
>>
>> $brandrequest = 'x';
>> $res = $db->multi_query( "CALL myproc($brandrequest, ModelID); " );
>> if (!$res ) {
>> echo 'No Listings were found for this request.';
>> echo mysql_error();
>> exit;
>> }
>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Is the multi_query call the correct one?
>
I did work with mysqli_multi_query also. The documentation seemed to
confuse the two. The only examples were like I have above.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 14.07.2009 12:29:09 von Richard Quadling
2009/7/13 Patrick Moloney :
> Bastien Koert wrote:
>>
>> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney
>> wrote:
>>>
>>> I've had no success trying to execute any stored procedure from php.
>>> I'm just trying to follow the example for multi-query in the php manual=
,
>>> and
>>> have tried an example from Artfulsoftware.com. I have one input and one
>>> output parameter. I've simplified the stored procedure to always output
>>> one
>>> value from one record, regardless of the value passed in.
>>> The SP works in Mysql. Just cant run it from php. It returns False.
>>> I look at the query log in mysql and it calls the stored procedure, and
>>> shows the input value and output variable. No further information. I'm
>>> not
>>> familiar with that log so I don't know what it should look like.
>>> The only thing I see looks like a brief reference to UTC8 - but I don't
>>> think I am (intentionally) using that anywhere. I get no other error ba=
ck
>>> or
>>> logged. I'm using root as the user, which is the only defined user.
>>> Should
>>> this work, or are stored procedures not working well?
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Can you show the php code?
>>
>
> Below is the relevant code. The database connection is established, but t=
he
> query call returns False. The call is recorded in the mysql query log. No
> error there or returned, but just False. Proc works in mysql and  ig=
nores
> the value of the input parameter and returns 1 string. But I can't get it=
to
> do that from php.
>
>
> Â Â @$db =3D new mysqli('localhost', 'root', 'password', 'Sales'=
);
> Â Â if (mysqli_connect_errno())
> Â Â { echo 'Error: could not connect to database. ';
> Â Â Â exit;
> Â Â }
>
> Â Â $brandrequest =3D 'x';
> Â Â $res =3D $db->multi_query( "CALL myproc($brandrequest, Model=
ID); " Â );
> Â Â if (!$res ) {
> Â Â Â echo 'No Listings were found for this request.';
> Â Â Â echo mysql_error();
> Â Â Â exit;
> Â Â }
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Isn't your SQL is broken?
CALL myproc(x, ModelID)
?
Surely ...
CALL myproc('x', 'ModelID')
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Cant get Mysql stored procedure to work.
am 14.07.2009 12:30:55 von Richard Quadling
2009/7/13 Patrick Moloney :
> Bastien Koert wrote:
>>
>> On Mon, Jul 13, 2009 at 1:33 PM, Patrick Moloney
>> wrote:
>>>
>>> Bastien Koert wrote:
>>>>
>>>> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney
>>>> wrote:
>>>>>
>>>>> I've had no success trying to execute any stored procedure from php.
>>>>> I'm just trying to follow the example for multi-query in the php
>>>>> manual,
>>>>> and
>>>>> have tried an example from Artfulsoftware.com. I have one input and o=
ne
>>>>> output parameter. I've simplified the stored procedure to always outp=
ut
>>>>> one
>>>>> value from one record, regardless of the value passed in.
>>>>> The SP works in Mysql. Just cant run it from php. It returns False.
>>>>> I look at the query log in mysql and it calls the stored procedure, a=
nd
>>>>> shows the input value and output variable. No further information. I'=
m
>>>>> not
>>>>> familiar with that log so I don't know what it should look like.
>>>>> The only thing I see looks like a brief reference to UTC8 - but I don=
't
>>>>> think I am (intentionally) using that anywhere. I get no other error
>>>>> back
>>>>> or
>>>>> logged. I'm using root as the user, which is the only defined user.
>>>>> Should
>>>>> this work, or are stored procedures not working well?
>>>>>
>>>>> --
>>>>> PHP Database Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>> Can you show the php code?
>>>>
>>> Below is the relevant code. The database connection is established, but
>>> the
>>> query call returns False. The call is recorded in the mysql query log. =
No
>>> error there or returned, but just False. Proc works in mysql and  =
ignores
>>> the value of the input parameter and returns 1 string. But I can't get =
it
>>> to
>>> do that from php.
>>>
>>>
>>> Â @$db =3D new mysqli('localhost', 'root', 'password', 'Sales');
>>> Â if (mysqli_connect_errno())
>>> Â { echo 'Error: could not connect to database. ';
>>> Â Â exit;
>>> Â }
>>>
>>> Â $brandrequest =3D 'x';
>>> Â $res =3D $db->multi_query( "CALL myproc($brandrequest, ModelID);=
" Â );
>>> Â if (!$res ) {
>>> Â Â echo 'No Listings were found for this request.';
>>> Â Â echo mysql_error();
>>> Â Â exit;
>>> Â }
>>>
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Is the multi_query call the correct one?
>>
>
> I did work with mysqli_multi_query also. The documentation seemed to conf=
use
> the two. The only examples were like I have above.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
If your stored procedure has in and out parameters, maybe the
mysqli::prepare() method may be of more use.
--=20
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php