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 Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/ 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? Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498153 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... Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498234 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)): Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498236 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". Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498239 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? Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498240 Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 bump Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498242 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 Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498243 Share on other sites More sharing options...
cello10 Posted December 1, 2014 Author Share Posted December 1, 2014 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 Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498244 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 Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498246 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. Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498247 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. Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498249 Share on other sites More sharing options...
cello10 Posted December 2, 2014 Author Share Posted December 2, 2014 OK, how can I find the content of the mysql_error()? And yes that is exactly the error message. Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498250 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! Link to comment https://forums.phpfreaks.com/topic/292820-connecting-to-database-and-displaying-the-row/#findComment-1498272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.