How can the syntax error related to the array offset in the mysql_query function be fixed in the given PHP code snippet?

The syntax error related to the array offset in the mysql_query function can be fixed by using curly braces to enclose the array offset. This ensures that the offset is properly interpreted by PHP. By enclosing the array offset in curly braces, the syntax error should be resolved.

$query = "SELECT * FROM users WHERE id = {$id}";
$result = mysql_query($query);