When I open a MySQL connection in PHP with just PHP\'s built-in MySQL functions, I do the following:
$link = mysql_connect($servername, $username, $password)
When the PHP script finishes executing, all connections are closed. Also you don't have to explicitly close your connection with mysql_close().
mysql_close()