What are the potential risks of using deprecated PHP functions like mysql_connect?

Deprecated PHP functions like mysql_connect pose potential risks such as security vulnerabilities, compatibility issues with newer PHP versions, and lack of support for modern database features. To mitigate these risks, it is recommended to switch to using MySQLi or PDO extensions for connecting to databases in PHP.

// Using MySQLi extension to connect to a MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

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

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