How can the error "#1064 - Fehler in der SQL-Syntax" be resolved in PHP?

The error "#1064 - Fehler in der SQL-Syntax" typically occurs when there is a syntax error in the SQL query being executed. To resolve this issue, carefully review the SQL query for any syntax errors such as missing quotes, incorrect table or column names, or misplaced punctuation. Once the syntax error is identified and corrected, the error should be resolved.

$sql = "SELECT * FROM users WHERE username = 'john'";
$result = mysqli_query($conn, $sql);

if (!$result) {
    die('Error: ' . mysqli_error($conn));
}

// Rest of the code to process the query result