What are the potential pitfalls of not properly quoting variables in SQL queries in PHP?

Not properly quoting variables in SQL queries in PHP can lead to SQL injection attacks, where malicious users can manipulate the query to access or modify sensitive data. To prevent this, always use prepared statements with parameterized queries or escape variables properly before including them in the SQL query.

// Example of using prepared statements to properly quote variables in SQL queries
$pdo = new PDO('mysql:host=localhost;dbname=my_database', 'username', 'password');
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username');
$stmt->bindParam(':username', $username);
$stmt->execute();
$results = $stmt->fetchAll();