What are the potential issues with using deprecated mysql_connect() function in PHP and how can they be addressed?

The potential issues with using the deprecated mysql_connect() function in PHP include security vulnerabilities and compatibility issues with newer versions of PHP. To address this, you should switch to using the MySQLi or PDO extension for connecting to a MySQL database.

// 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";