What potential pitfalls should be considered when using PHP to manipulate user data?

One potential pitfall when using PHP to manipulate user data is the risk of SQL injection attacks if user input is not properly sanitized. To prevent this, always use prepared statements and parameterized queries when interacting with a database in PHP.

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