What are the drawbacks of using the mysql_connect function in PHP?

The mysql_connect function is deprecated in newer versions of PHP and should not be used due to security vulnerabilities and lack of support. It is recommended to use mysqli or PDO extensions for connecting to MySQL databases in PHP.

// Using mysqli to connect to a MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$database = "database";

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

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