Why is using mysql_* functions in PHP considered outdated and insecure?

Using mysql_* functions in PHP is considered outdated and insecure because they are deprecated as of PHP 5.5 and removed in PHP 7. Instead, it is recommended to use MySQLi or PDO extensions, which offer better security features like prepared statements to prevent SQL injection attacks.

// Using MySQLi extension to connect to MySQL database
$mysqli = new mysqli('localhost', 'username', 'password', 'database_name');

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