What are the potential issues with using the mysql_* extension in PHP and what are the recommended alternatives?

The mysql_* extension in PHP is deprecated and has been removed in PHP 7. It is not secure and vulnerable to SQL injection attacks. It is recommended to use either the MySQLi extension or PDO (PHP Data Objects) for database operations in PHP.

// Using MySQLi extension
$mysqli = new mysqli("localhost", "username", "password", "database");

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Using PDO
$pdo = new PDO("mysql:host=localhost;dbname=database", "username", "password");