Why is it recommended to use mysqli_* or PDO functions for database connections in PHP instead of mysql_* functions?

Using mysqli_* or PDO functions for database connections in PHP is recommended over mysql_* functions because mysql_* functions are deprecated as of PHP 5.5.0 and removed as of PHP 7.0.0. This means that mysql_* functions are no longer supported in the latest versions of PHP and may cause compatibility issues or security vulnerabilities. mysqli_* and PDO functions offer more features, better security, and support for prepared statements, making them the preferred choice for interacting with databases in PHP.

// Using mysqli_* functions for database connection
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";

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

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