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: 

Link to comment
Share on other sites

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 by cello10
Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.