I cannot figure out why I am getting this error,
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in F:\xampp\htdocs\HWFive\bookdisplay.php on line 11

My php code is as follows

<?php
$dbc = mysqli_connect(DBHOST,DBUSER,DBPASSWORD,DBNAME);

  $query = "SELECT * FROM 'book'";
 $data = mysqli_query($dbc,$query);


   echo "<table>";
   	 echo "<tr bgcolor='gray'><td>Update</td><td>BookAuthor</td><td>Booktitle</td><td>Delete</td></tr>"; 

 while ($row = mysqli_fetch_array($data)){
 echo"<tr>";

echo"<td><a href='bookdelete.php?id=".$row['bookid,']."'>Remove: ".$row['bookid']."</a></td>";

//echo "<td><a href='bookdelete.php?id=".$library."'>Remove:".$library."</a></td>";
   // echo "<td>".$Booktitle,"</td>";
    echo "<td>".$row['Booktitle']."</td>";
    //echo "<td>".$bookauthor,"</td>";
    echo "<td>".$row['bookauthor']."</td>";
    //echo "<td>".$bookid,"</td>";

echo"<tr>";


}   
  echo"<td><a href='bookupdate.php?id=".$row['bookid,']."'>Update: ".$row['bookid']."</a></td>";
    //echo "<td><a href='bookupdate.php?id=".$library."'>Update: ".$library."</a></td>";
 // }
     echo "</table>";
     	//	require('bookform.php');

//	require('booklistings.php');
 ?>

Any ideas?

    As the error message states, you passed a boolean value to mysqli_fetch_array(). $data contains boolean FALSE since you have an error in your SQL query. Database identifiers (names of columns, tables, databases, views, etc.) can not be surrounded by single quotes (since those are used for strings, after all). For MySQL, you can either use the backtick (`) or nothing at all (assuming the identifier in question isn't a reserved word).

    In the future, common SQL debugging methods involve replacing something like this:

    $data = mysqli_query($dbc,$query); 

    with something like this:

    $data = mysqli_query($dbc,$query) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $query");

    The above allows you to visually inspect the query as well as read the error message returned from the MySQL server.

      Write a Reply...