What are the potential risks of using outdated functions like mysql_* in PHP?

Using outdated functions like mysql_* in PHP poses security risks as these functions are deprecated and no longer maintained. This can lead to vulnerabilities such as SQL injection attacks. To mitigate this risk, it is recommended to use modern alternatives like PDO or MySQLi which provide better security features and support prepared statements.

// Using PDO to connect to a MySQL 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();
}