We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,697 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

mysql_fetch_assoc($result)

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>';
}

?>
2
Contributors
1
Reply
8 Minutes
Discussion Span
6 Months Ago
Last Updated
2
Views
amras123
Newbie Poster
15 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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());
}
deceptikon
Challenge Accepted
Administrator
3,426 posts since Jan 2012
Reputation Points: 822
Solved Threads: 473
Skill Endorsements: 56

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0588 seconds using 2.73MB