What potential pitfalls should be considered when using SQL syntax in PHP scripts?
One potential pitfall when using SQL syntax in PHP scripts is the risk of SQL injection attacks if user input is not properly sanitized. To prevent this, it is important to use prepared statements with parameterized queries instead of directly inserting user input into SQL queries.
// Using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
$stmt->execute();