What is the difference between mysqli_ and mysql_ functions in PHP?

The main difference between mysqli_ and mysql_ functions in PHP is that mysqli_ functions are the improved version of mysql_ functions and offer more features and security enhancements. It is recommended to use mysqli_ functions for database operations in PHP as mysql_ functions are deprecated and not supported in newer versions of PHP.

// Example of connecting to a MySQL database using mysqli_ functions
$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";