What are common pitfalls or errors that users may encounter when trying to switch from mysql to PDO in PHP?

One common pitfall when switching from MySQL to PDO in PHP is not properly handling errors or exceptions. It's important to set PDO to throw exceptions on errors to catch and handle them appropriately. Another issue is not updating SQL queries to use PDO prepared statements, which can lead to SQL injection vulnerabilities.

// Set PDO to throw exceptions on errors
$pdo = new PDO($dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));

// Update SQL queries to use prepared statements
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->execute(array(':username' => $username));