What is causing the "Call to a member function mysqli_fetch_object() on boolean" error in the provided PHP code?
The error "Call to a member function mysqli_fetch_object() on boolean" occurs when the query execution returns a boolean value (false) instead of a result set. This can happen if there is an issue with the SQL query or database connection. To solve this issue, you should check if the query execution was successful before calling mysqli_fetch_object().
// Check if the query execution was successful before fetching the result
$result = mysqli_query($conn, $query);
if($result) {
while($row = mysqli_fetch_object($result)) {
// Process the fetched data
}
} else {
echo "Error executing query: " . mysqli_error($conn);
}