1,105,254 Community Members

mysql_fetch_assoc($result)

Member Avatar
amras123
Newbie Poster
15 posts since Jan 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in \xampp\htdocs\proj\demo.php on line 57

Can anyone explain my problem. Thanks!

<?php

$result = mysql_query("SELECT * FROM internet_shop");
while($row=mysql_fetch_assoc($result))
{
    echo '<div class="product"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></div>';
}

?>
Member Avatar
deceptikon
Eternally Awesome
4,684 posts since Jan 2012
Reputation Points: 1,341 [?]
Q&As Helped to Solve: 684 [?]
Skill Endorsements: 104 [?]
Administrator
Featured
 
1
 

The error suggests that mysql_query() returned FALSE as mentioned is one possible return value here. You need to extract more information to properly diagnose the failure:

$query = ''SELECT * FROM internet_shop';
$result = mysql_query($query);

if (!$result) {
    die("'$query' failed with error: " . mysql_error());
}
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article