What are common syntax errors to look out for when using PHP and MySQL together?

One common syntax error to look out for when using PHP and MySQL together is not properly escaping strings in SQL queries, which can lead to SQL injection attacks. To solve this issue, you should use prepared statements with parameterized queries to securely pass data to the database.

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