What happens when a MySQL connection is not closed? [duplicate]
Possible Duplicate:
What happens if MySQL connections continually aren't closed on PHP pages?
If you forget sometimes to close the connection will be close in a while, automatically or will be stay open?
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
$db = mysql_select_db(DB_DATABASE);
.
.
your code
.
.
and you forget to mysql开发者_如何学JAVA_close($link);
From mysql_connect()
function documentation:
Note
The link to the server will be closed as soon as the execution of the script ends, unless it's closed earlier by explicitly calling
mysql_close()
.
PS. You should consider moving to PDO or at least mysqli driver.
MySQL connections are automatically closed at the end of the script's execution. See PHP docs.
精彩评论