How can error handling be improved in PHP scripts that involve database updates to provide more informative feedback to the user?

When handling errors in PHP scripts that involve database updates, it's important to provide informative feedback to the user to understand what went wrong. One way to improve error handling is to use try-catch blocks to catch exceptions thrown during database operations and provide detailed error messages to the user.

try {
    // Perform database update operation here
    // Example: $query = "UPDATE table SET column = value WHERE condition";
    
    if ($success) {
        echo "Update successful!";
    } else {
        echo "Update failed.";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}