What is the potential issue with using the mysql extension in PHP and why is it recommended to use MySQLi or PDO instead?

The potential issue with using the mysql extension in PHP is that it is deprecated as of PHP 5.5.0 and removed in PHP 7.0.0, meaning it is no longer supported and may pose security risks. It is recommended to use MySQLi (MySQL Improved) or PDO (PHP Data Objects) extensions instead, as they offer more features, better security, and support for prepared statements to prevent SQL injection attacks.

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

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

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

echo "Connected successfully";