What is the common error message related to SQL syntax in PHP and how can it be resolved?

Common error message related to SQL syntax in PHP is "Syntax error in SQL statement." This error occurs when there is a mistake in the SQL query syntax, such as missing quotes around strings, incorrect table or column names, or incorrect SQL keywords. To resolve this issue, carefully review the SQL query and ensure that it follows the correct syntax rules.

// Example of resolving SQL syntax error
$sql = "SELECT * FROM users WHERE username = 'john'";
$result = mysqli_query($conn, $sql);

if ($result) {
    // Process the query result
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}