What are the potential security risks associated with not properly handling SQL injections in PHP?

SQL injections in PHP can lead to unauthorized access to databases, data manipulation, and potentially the exposure of sensitive information. To prevent SQL injections, it's crucial to use parameterized queries or prepared statements when interacting with a database in PHP. This helps sanitize user input and prevents malicious SQL code from being executed.

// Using parameterized queries to prevent SQL injections
$pdo = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password');
$stmt = $pdo->prepare('SELECT * FROM users WHERE username = :username AND password = :password');
$stmt->execute(['username' => $username, 'password' => $password]);