What are some common pitfalls when using SQL queries in PHP for data manipulation?

One common pitfall when using SQL queries in PHP for data manipulation is SQL injection attacks, where malicious SQL statements are inserted into input fields. To prevent this, you should always use prepared statements with parameterized queries to sanitize user input.

// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (:username, :password)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password', $password);
$stmt->execute();