What common syntax errors can lead to issues with MySQL queries in PHP code?

One common syntax error that can lead to issues with MySQL queries in PHP code is not properly escaping strings within the query. This can result in SQL injection attacks or errors when executing the query. To solve this issue, it is recommended to use prepared statements with parameterized queries to securely pass user input to the database.

// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
$stmt->execute();