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))
	SELECT name INTO name_out FROM table WHERE name=name_in;

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?


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);

if($name_out = $$name_from_db)
echo "It's John";

I am not expert in Php though

Because, i want to learn how to read OUT parameter.

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");