What is the correct syntax for updating a database record in PHP using the mysql_query function?

When updating a database record in PHP using the mysql_query function, you need to construct a SQL query that specifies the table and columns to update, as well as the new values. Make sure to properly sanitize user input to prevent SQL injection attacks. Additionally, you should establish a database connection before executing the query.

<?php
// Establish a connection to the database
$conn = mysql_connect("localhost", "username", "password");
mysql_select_db("database_name", $conn);

// Sanitize user input and construct the update query
$updatedValue = mysql_real_escape_string($updatedValue);
$query = "UPDATE table_name SET column_name = '$updatedValue' WHERE condition";

// Execute the update query
$result = mysql_query($query);

// Check if the update was successful
if($result){
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . mysql_error();
}

// Close the database connection
mysql_close($conn);
?>