What are the potential security risks associated with using outdated mysql_* functions in PHP code?

Using outdated mysql_* functions in PHP code poses security risks such as SQL injection vulnerabilities, as these functions do not support parameterized queries. To mitigate these risks, it is recommended to switch to using mysqli or PDO for interacting with a MySQL database, as they provide better security features like prepared statements.

// Connect to MySQL database using mysqli
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}