I found this error whenever I query from the database.
Connected successfully0 resultsDatabase error: Query was empty Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\digicraft\index.php on line 20
There are 2 records in my table & when I want to fetch that it says that Query was empty.
$servername = "localhost";
$username = "admin";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
//Query
$query = "SELECT * FROM pages WHERE id = 1";
$result = mysqli_query($dbc, $query);
if (! $result){
echo ('Database error: ' .mysql_error());
}
while($row = mysql_fetch_assoc($result)){
//handle rows.
$title = $row['title'];
$header = $row['header'];
$body = $row['body'];
}