What are the advantages of using mysqli_* or PDO functions over mysql_* in PHP?

Using mysqli_* or PDO functions over mysql_* in PHP is recommended because mysql_* functions are deprecated as of PHP 5.5.0 and removed in PHP 7.0.0. mysqli_* and PDO offer better security features such as prepared statements to prevent SQL injection attacks. They also provide support for multiple database systems, making your code more flexible and easier to maintain.

// Using mysqli_* functions
$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");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);