What are common pitfalls when using single quotes in PHP queries?

Common pitfalls when using single quotes in PHP queries include not properly escaping the single quotes within the query string, which can lead to syntax errors or SQL injection vulnerabilities. To avoid this issue, use double quotes for the query string and single quotes for values within the query. Example:

// Incorrect way with single quotes in query string
$query = 'SELECT * FROM users WHERE username = \'' . $username . '\'';

// Correct way with double quotes for query string and single quotes for values
$query = "SELECT * FROM users WHERE username = '$username'";