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

The mysql_connect function in PHP is deprecated and has been removed in newer versions of PHP. This function is insecure and can lead to potential security vulnerabilities such as SQL injection attacks. It is recommended to use mysqli or PDO for database connections in PHP to ensure better security and compatibility with newer PHP versions.

// Using mysqli for database connection
$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";