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)
You can also limit your connections to within local functions. That way the connection is closed as soon as the function is completed.