Jump to content

Stored Procedure error


raduenea

Recommended Posts

Hi

I create a stored procedure in mysql to show all the data from "biografie" table:

BEGIN
SELECT *  FROM biografie;
END 

 

In PHP a write the following code:

<?
$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 ?

Link to comment
https://forums.phpfreaks.com/topic/246911-stored-procedure-error/
Share on other sites

I thing I got it.

 

To create the procedure:

DELIMITER //
CREATE PROCEDURE produse
     (
        IN   pid                    INT(11)       ,
        OUT p_titlu                      VARCHAR(15)   
     )
BEGIN
    SELECT titlu
    INTO   p_titlu
    FROM   produse
    WHERE  id = pid ;
END
//
DELIMITER ; 

 

To call and show:

CALL produse
   (
      1,
      @p_titel
   );

SELECT @p_titel       AS p_titel  

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.