What are some common pitfalls to avoid when debugging PHP code that involves database queries?

One common pitfall to avoid when debugging PHP code that involves database queries is not properly handling errors or exceptions. It's important to check for errors after executing a query and handle them appropriately to prevent unexpected behavior or security vulnerabilities.

// Example of handling errors in a database query
$query = "SELECT * FROM users";
$result = mysqli_query($connection, $query);

if (!$result) {
    die("Error: " . mysqli_error($connection));
}

// Continue processing the query results