I am following Head First PHP and MYSQL by Oreily and I got stuck with an error which I can not figure out how to fix it. I double checked all the syntax and still nothing. If anyone can help, ill really appreciate it.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/giladal/public_html/guitarwars/admin.php on line 21
Here is the link: http://www.giladwebdesign.com/guitarwars/admin.php
If anyone can help me, I will greatly appreciate it.
And this is the code:
Code: Select all
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Guitar Wars - Admin</title>
</head>
<body>
<?php
require_once('includes/constants.php');
//Connect to the database
$dbc= mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
//retrieve the score data from the MySQL
$query = "SELECT * FROM guitarwars ORDER BY score DESC, date, ASC";
$data = mysqli_query($dbc, $query);
//Loop through the array of score data, formatting it as HTML
echo'<table>';
while($row= mysqli_fetch_array($data)) {
//Display the score data
echo '<tr class="scorerow"><td><strong>' . $row['name'] . '</strong></td>';
echo '<td>' . $row['date'] . '</td>';
echo '<td>' . $row['score'] . '</td>';
echo '<td><a href="removescore.php?id=' . $row['id'] . '$amp;date=' . $row['date'] .
'&name=' . $row['name'] . '$amp;sore=' . $row['score'] . '&screenshot=' .
$row['screenshot'] . '">Remove</a></td></tr>';
}
echo '</table>';
mysqli_close($dbc);
?>
</body>
</html>