What is the correct syntax for the mysql_connect function in PHP?

The correct syntax for the mysql_connect function in PHP is as follows: mysql_connect(hostname, username, password). The issue might arise if the function is not called with the correct parameters, leading to errors in connecting to the MySQL database. To solve this, make sure to provide the hostname, username, and password as arguments in the correct order when calling the mysql_connect function.

$hostname = "localhost";
$username = "root";
$password = "password";

$conn = mysql_connect($hostname, $username, $password);

if (!$conn) {
    die("Connection failed: " . mysql_error());
} else {
    echo "Connected successfully";
}