| | |
Reading OUT param in stored procedure
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 497
Reputation:
Solved Threads: 0
Hi,
Stored proc code below works fine in MySQL command prompt. It returns John because it is in table. However, i can't return or read the Out parametter in PHP. I mean i cant retrieve John. I did ask this in PHP forum but no answer.
What do i write to check if result is returns John or not?
Thanks
Stored proc code below works fine in MySQL command prompt. It returns John because it is in table. However, i can't return or read the Out parametter in PHP. I mean i cant retrieve John. I did ask this in PHP forum but no answer.
MySQL Syntax (Toggle Plain Text)
CREATE PROCEDURE `findname`(IN name_in VARCHAR(15), OUT name_out VARCHAR(15)) BEGIN SELECT name INTO name_out FROM table WHERE name=name_in; END; CALL findname('John', @out); SELECT @out;
MySQL Syntax (Toggle Plain Text)
$query = "CALL findname('John', @err);"; $run = mysql_query("SELECT @err");
What do i write to check if result is returns John or not?
Thanks
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Solved Threads: 8
Why cant you run a single query
Some thing like this....
$sql = "SELECT name FROM table WHERE nam='$name_out'";
$result = mysql_query($sql, $db);
$row = mysql_fetch_row($result);
$name_from_db=$row[0];
if($name_out = $$name_from_db)
{
echo "It's John";
exit;
}
I am not expert in Php though
MySQL Syntax (Toggle Plain Text)
SELECT name FROM table WHERE name=name_in;
Some thing like this....
$sql = "SELECT name FROM table WHERE nam='$name_out'";
$result = mysql_query($sql, $db);
$row = mysql_fetch_row($result);
$name_from_db=$row[0];
if($name_out = $$name_from_db)
{
echo "It's John";
exit;
}
I am not expert in Php though
Last edited by varmadba; Sep 4th, 2008 at 10:11 am.
:- Varma
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
•
•
Join Date: Jun 2008
Posts: 79
Reputation:
Solved Threads: 8
Just My taught
@out variable means you are creating a temporary variable
Temporary variables are connection specific
make sure these both are executed on one connection
@out variable means you are creating a temporary variable
Temporary variables are connection specific
make sure these both are executed on one connection
MySQL Syntax (Toggle Plain Text)
$query = "CALL findname('John', @err);"; $run = mysql_query("SELECT @err");
:- Varma
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
![]() |
Other Threads in the MySQL Forum
- Previous Thread: Please seriously HELP ME!
- Next Thread: pass php variables to mysql database
| Thread Tools | Search this Thread |
1 agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns cmg communityjournalism contentmanagement contractors copyright count court data database design developer development distinct drupal dui ec2 email enter enterprise error eudora facebook form foss gnu government gpl greenit groklaw hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire law legal license licensing maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





