What are the potential risks of using the mysql_connect function in PHP for database connection?

The mysql_connect function in PHP is deprecated and should not be used as it is no longer supported in newer versions of PHP. Instead, developers should use the mysqli or PDO extensions for connecting to a MySQL database to ensure compatibility and security.

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

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

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