What are the differences between using mysql functions and mysqli functions in PHP?

When using MySQL functions in PHP, you are using the older MySQL extension which is now deprecated and removed in PHP 7. Instead, it is recommended to use the improved MySQLi extension which offers better security and performance features. Here is an example of how to connect to a MySQL database using MySQLi functions in PHP:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$database = "dbname";

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

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

echo "Connected successfully";
?>