What are the advantages of using mysqli or PDO over the deprecated mysql_* functions for database operations in PHP?

The mysql_* functions in PHP are deprecated and no longer recommended for database operations due to security vulnerabilities and lack of support for modern database features. It is recommended to use mysqli (MySQL Improved) or PDO (PHP Data Objects) for database operations in PHP as they offer better security, support for prepared statements to prevent SQL injection, and compatibility with multiple database systems.

// Using mysqli for database operations
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Perform database operations using mysqli

$mysqli->close();