Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql_close()?

Status
Not open for further replies.

alphacooler

Programmer
Aug 29, 2005
73
US
Should I be using mysql_close() at the end of all my scripts? I've been told that using non-persitant connections will result in the connection closing once the script is finished. Thoughts?

Thanks.
 
php will close the connection to the mysql database after the script has concluded. there is (usually) no need to use mysql_close() in a typical web-application.
 
The PHP online manual entry for mysql_close() reads in part:

Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.

"Freeing resources" is the text for a link to . The pertinent section reads:
Due to the reference-counting system introduced with PHP 4's Zend Engine, it is automatically detected when a resource is no longer referred to (just like Java). When this is the case, all resources that were in use for this resource are made free by the garbage collector. For this reason, it is rarely ever necessary to free the memory manually by using some free_result function.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top