What is the correct syntax for establishing a database connection in PHP using the mysql_connect function?

When establishing a database connection in PHP using the mysql_connect function, it is important to provide the correct parameters in the function call. The syntax for mysql_connect requires the hostname, username, password, and optionally the client_flags. Make sure to replace 'hostname', 'username', and 'password' with your actual database credentials. Additionally, it is recommended to use mysqli or PDO instead of mysql_connect as it is deprecated in newer versions of PHP.

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

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

if (!$connection) {
    die('Could not connect: ' . mysql_error());
}

echo 'Connected successfully';