raduenea Posted September 11, 2011 Share Posted September 11, 2011 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 More sharing options...
fenway Posted September 11, 2011 Share Posted September 11, 2011 My guess? The delimiter. But if you dumped the error, you might know. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268007 Share on other sites More sharing options...
raduenea Posted September 11, 2011 Author Share Posted September 11, 2011 This is the exact code that I used in mysql: DELIMITER // CREATE PROCEDURE biografie() BEGIN SELECT * FROM biografie; END // DELIMITER ; and the error persists. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268011 Share on other sites More sharing options...
fenway Posted September 11, 2011 Share Posted September 11, 2011 Still -- no error provided. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268022 Share on other sites More sharing options...
raduenea Posted September 11, 2011 Author Share Posted September 11, 2011 still returns an error. If I replace $q = mysql_query("CALL biografie()"); with $q = mysql_query("SELECT * FROM biografie; "); it's working. So it's something wrong on the procedure, but I don't know why. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268025 Share on other sites More sharing options...
fenway Posted September 11, 2011 Share Posted September 11, 2011 I can't help you anymore -- you're not supplying the required information -- maybe someone who speaks Romanian can. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268045 Share on other sites More sharing options...
raduenea Posted September 11, 2011 Author Share Posted September 11, 2011 I can't help you anymore -- you're not supplying the required information -- maybe someone who speaks Romanian can. What kind of information can I provided to you ? Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268067 Share on other sites More sharing options...
fenway Posted September 11, 2011 Share Posted September 11, 2011 What error did you get from mysql_query()? Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268137 Share on other sites More sharing options...
raduenea Posted September 12, 2011 Author Share Posted September 12, 2011 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 Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268443 Share on other sites More sharing options...
fenway Posted September 12, 2011 Share Posted September 12, 2011 You know, it's funny -- you ask for help. Then you ask for clarification about the help you're offered. And then you go about solving the problem on your own anyway. So why bother posting the in first place? Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268455 Share on other sites More sharing options...
raduenea Posted September 12, 2011 Author Share Posted September 12, 2011 I didn't know that I will solve the problem so quickly. That's why I write here for help. Anyway, thanks. Link to comment https://forums.phpfreaks.com/topic/246911-stored-procedure-error/#findComment-1268479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.