-1

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource problem

This is part of a dynamic menu on the website, where I'm taking the name of the collections from the database. This is my database structure

id INT (11)
name VARCHAR (255)

And this is my script

<?php
include("connect.php");
$query = mysql_query("SELECT * FROM collections");
while($row=mysql_fetch_array($query)){
    echo '<li><a href="photohandler.php?c='.$row['id'].'" class="parent"><span>'.$row['name'].'</span></a>';
}
?>

I receive the error:

mysql_fetch_array() expects parameter 1 to be resource, boolean given in index.php on line 107

Community
  • 1
  • 1

1 Answers1

0

Seems Your query has failed somehow, and returned a boolean FALSE instead of a statement handle.

Like below:

<?php
            include("connect.php");
             $query = mysql_query("SELECT * FROM collections");
             if ($query === FALSE) {
                 die(mysql_error());
              }

              if(mysql_num_rows($query) > 0)
              {
             while($row=mysql_fetch_array($query)){
                 echo
            '<li><a href="photohandler.php?c='.$row['id'].'" class="parent"><span>'.$row['name'].'</span></a>';
              }
           }
?>