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 ? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 11, 2011 Share Posted September 11, 2011 Still -- no error provided. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 ? Quote Link to comment 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()? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.