What are the potential pitfalls of using outdated PHP functions like mysql_* instead of PDO or mysqli?

Using outdated PHP functions like mysql_* can pose security risks as they are deprecated and no longer supported. These functions are vulnerable to SQL injection attacks and lack important features like prepared statements. To mitigate these risks, it is recommended to switch to PDO or mysqli for database operations.

// Using PDO to connect to a database
$dsn = 'mysql:host=localhost;dbname=mydatabase';
$username = 'username';
$password = 'password';

try {
    $pdo = new PDO($dsn, $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}