What is the potential issue with using the mysql_connect function in PHP, and what alternative should be used?

The potential issue with using the mysql_connect function in PHP is that it is deprecated as of PHP 5.5.0 and removed in PHP 7.0.0. It is recommended to use the mysqli_connect function or PDO (PHP Data Objects) for connecting to a MySQL database in PHP.

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

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

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