Jump to content

Connecting to Database and Displaying the Row


cello10

Recommended Posts

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...  ;D

 

<?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  :sweat: 

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

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.

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.