How can error reporting be effectively utilized in PHP to troubleshoot issues like updates not being applied to a database?

When updates are not being applied to a database in PHP, one common issue could be related to errors occurring during the update process. To troubleshoot this, error reporting can be effectively utilized to identify and address any errors that are preventing the updates from being applied to the database.

// Enable error reporting to display any errors that occur during the update process
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Perform the database update operation
$query = "UPDATE table_name SET column_name = 'new_value' WHERE condition";
$result = mysqli_query($connection, $query);

// Check for errors during the update process
if (!$result) {
    echo "Error: " . mysqli_error($connection);
} else {
    echo "Update successful!";
}