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

Using deprecated functions like mysql_* in PHP code can pose security risks as these functions are no longer maintained and may contain vulnerabilities that can be exploited by attackers. Additionally, deprecated functions may not be compatible with newer versions of PHP, leading to potential errors and issues in the code. To mitigate these risks, it is recommended to switch to using mysqli or PDO for database operations in PHP.

// Fix for using deprecated mysql_* functions
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

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

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