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.

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;
$query = "CALL findname('John', @err);";
$run = mysql_query("SELECT @err");

What do i write to check if result is returns John or not?

Thanks

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by varmadba
0

Why cant you run a single query

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

0

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

$query = "CALL findname('John', @err);";
$run = mysql_query("SELECT @err");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.