How can SQL errors be effectively debugged and displayed when updating variables in a PHP script?

To effectively debug and display SQL errors when updating variables in a PHP script, you can use try-catch blocks to catch any exceptions thrown by the SQL query execution. Within the catch block, you can retrieve the error message using the `getMessage()` method and display it to the user for debugging purposes.

try {
    // Your SQL update query here
    $query = "UPDATE table SET column = :value WHERE id = :id";
    $stmt = $pdo->prepare($query);
    $stmt->bindParam(':value', $value);
    $stmt->bindParam(':id', $id);
    $stmt->execute();
} catch (PDOException $e) {
    echo "Error updating record: " . $e->getMessage();
}