Page 1 of 1

Stored Procedure error

Posted: Sun Sep 11, 2011 9:47 am
by dotphp
Hi
I create a stored procedure in mysql to show all the data from "biografie" table:

Code: Select all

DELIMITER //
CREATE PROCEDURE biografie()
 BEGIN
SELECT *  FROM biografie;
 END //
DELIMITER ;
In PHP a write the following code:

Code: Select all

<?
$conexiune=mysql_connect($host,$user,$pass) or die ("conexiunea nu a fost stabilita");
mysql_select_db ($db,$conexiune) or die ("nu sa conectat la baza de date"); 

$q = mysql_query("CALL biografie()");
while($qw = mysql_fetch_assoc($q))
{
   echo $qw['id'].'<br>';
}

?> 
And it show the following error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/picturi/public_html/test.php on line 23

Can you please tell where it's the error ?

Re: Stored Procedure error

Posted: Sun Sep 11, 2011 10:27 am
by ok
I think you need to define an output parameter as described in the mysql documentation:
http://dev.mysql.com/doc/refman/5.0/en/ ... edure.html
(See the first example there)