What are common SQL syntax errors that PHP developers may encounter when querying databases?

One common SQL syntax error that PHP developers may encounter is forgetting to properly escape strings in their queries, leading to SQL injection vulnerabilities. To solve this issue, developers should use prepared statements with placeholders to safely 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();
```

Another common syntax error is using incorrect SQL keywords or functions in the query, which can lead to errors in retrieving data from the database. To solve this, developers should double-check their SQL syntax and ensure they are using the correct keywords and functions.

```php
// Example of using correct SQL syntax
$stmt = $pdo->query("SELECT * FROM users WHERE status = 'active'");
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);