Jordan Davis Jordan Davis - 2 years ago 94
PHP Question

calling a stored procedure from php

I'm calling a stored procedure from php

$id = 1;
$base = conn();
$query = "CALL get_id(:id,@userid)";
$stmt = $base->prepare($query);

the stored procedure looks like this

SET @userid = (SELECT * FROM user WHERE = id);
SELECT @userid;

the procedure parameters

IN id int(10), OUT userid VARCHAR(255)


  • why does my result return nothing?

  • what data type does my output variable
    need to be?

Answer Source

Your Store procedure has some problems
Since you have an output userid why this @userid
Also you are outputing userid , So there is no need to SELECT it

Another thing is , you can't select the entire row into a single variable, for multiple columns you should use multiple output variables.

SET userid = (SELECT column_name FROM user WHERE = id);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download