cello10 Posted December 1, 2014 Share Posted December 1, 2014 So I've followed this code, corrected about 12 error, talked to my hosting and I am so done. I have tried everything but the error won't go away. The code is pasted below. As it's really late any help would be appreciated that would make my day the next day... <?PHP //connect to server $connect = mysql_connect("localhost","cello10_import","brigite27"); //connection to database mysql_select_db("cello10_import"); //query the database $query = mysql_query("SELECT * FROM users WHERE cover_image = 'http://d1w7fb2mkkr3kw.cloudfront.net/assets/images/book/small/9781/2500/9781250038821.jpg' "); //fetch the results / convert into array WHILE($rows = mysql_fetch_array(query)): $cover_image = $rows['cover_image']; $title = $rows['title']; $author = $rows['author']; echo "$cover_image<br>$title<br>$author<br><br><br>"; endwhile; ?> The error experienced is: Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/cello10/public_html/display.php on line 10 Thanks for your help Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 1, 2014 Share Posted December 1, 2014 WHILE($rows = mysql_fetch_array(query)): Can you tell us what query is? Specifically, query without the dollar sign that, if present, would indicate it is a variable? Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 What do you mean with query? It's all I have besides the database... I didn't create anything else??? Please elaborate... Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2014 Share Posted December 1, 2014 Let's be less subtle and try the spoonfeeding approach WHILE($rows = mysql_fetch_array(query)): should be WHILE($rows = mysql_fetch_array($query)): Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 OK, I'm sure it works, try it out in a moment but I want to know how the solution works in response to the error? Thanks for the "spoonfeeding approach". Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 Let's be less subtle and try the spoonfeeding approach should be Still gives the same error. Any other ideas? Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 bump Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2014 Share Posted December 1, 2014 Are you sure it is exactly the same error message? Try echo mysql_error(); after the query and tell us what that gives Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 (edited) OK, when there is no $ sign on the query the message is as follows Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in /home/cello10/public_html/display.php on line 10 if it's $query as you told me then it's Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/cello10/public_html/display.php on line 10 Edited December 1, 2014 by cello10 Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2014 Share Posted December 1, 2014 Try echo mysql_error(); after the query and tell us what that gives Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 Try echo mysql_error(); after the query and tell us what that gives Already tried that but still generates the same result. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 2, 2014 Share Posted December 2, 2014 The reason you get the error message Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/cello10/public_html/display.php on line 10 is because the query failed for some reason. What that reason is will be given by the contents of mysql_error(). If you don't want to tell us what that it is, then fine, you sort it because we cannot see it for ourselves. Bye. Quote Link to comment Share on other sites More sharing options...
cello10 Posted December 2, 2014 Author Share Posted December 2, 2014 (edited) OK, how can I find the content of the mysql_error()? And yes that is exactly the error message. Edited December 2, 2014 by cello10 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted December 2, 2014 Share Posted December 2, 2014 OK, how can I find the content of the mysql_error()? And yes that is exactly the error message. You echo it as Barand has told you to do in posts #8, #10 and #12 all of you which you have ignored! 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.