What are common issues with MySQL statements in PHP scripts, and how can they be resolved?

Issue: One common issue with MySQL statements in PHP scripts is not properly escaping input data, which can lead to SQL injection attacks. To resolve this, use prepared statements with parameterized queries to safely handle user input.

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