Assuming you have both mysql and php properly installed, the documented function will work.
Copied verbatim from the manual:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Could not connect");
print ("Connected successfully");
mysql_close($link);
?>
Presumably you would want to do something useful before closing the connection.