1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

How to close your MySQL connection from PHP


If you open a connection to MySQL within your PHP file you can close it again by using the mysql_close () function. Not all programs use this. Some find it is unnecessary, because MySQL connections are usually closed by default at the end of the script.

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password') ;
if (!$link)
die(mysql_error()) ;
print 'You are connected';
mysql_close($link) ;

©2014 About.com. All rights reserved.