How can the use of single and double quotes impact SQL syntax errors in PHP?

When writing SQL queries in PHP, using single quotes for string values and double quotes for SQL syntax can help prevent syntax errors. Mixing up the quotes can lead to errors in the SQL query execution. To avoid this, consistently use single quotes for values and double quotes for SQL syntax in PHP.

// Correct way to write SQL query in PHP
$query = "SELECT * FROM users WHERE username = '$username'";