Hi, I am getting this error message and would like some help figuring out where I'm going wrong. The error message that I'm getting is this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in... The lines of code that it is referring to are these: $read = " SELECT * freewebsitehostingreviews_com_reviews WHERE host='$host' && display_post='YES' "; $result = mysql_query($read); while($row = mysql_fetch_array($result)) { echo '<p><br />' . $row['post_date'] . '<br />' . $row['reviews'] . '</p>'; } Code (markup):
You got this error is because the $result being returned is not a mysql result set. It means that there is something wrong with your "SELECT" statement or mysql connection. Add this to your code $result = mysql_query($read) or die(mysql_error()); die(mysql_error()) will tell you more about the error that you got. Little John
$read = "SELECT * FROM freewebsitehostingreviews_com_reviews WHERE host='$host' && display_post='YES'"; $result = mysql_query($read); while($row = mysql_fetch_array($result)) { $pdate= $row['post_date']; $review=$row['reviews']; echo "<p><br />" . $pdate . "<br />" . $review . "</p>"; } PHP:
$result = mysql_query($read) .. mysql_fetch_array(): supplied argument is not a valid because the data in the $result is not an array. Try echo $result and see if all the fields are displayed or not
You have to fix your query first, you're missing the "FROM" keyword and you must also use the ANSI-SQL standard "AND" operator, not the PHP "&&" (although mysql will happily accpet it): $read = " SELECT * FROM freewebsitehostingreviews_com_reviews WHERE host='$host' AND display_post='YES' "; PHP: It is also a good practice to use mysql_error() when your query fails for some reason: $result = mysql_query($read) or die(mysql_error()); PHP: