WarKirby Posted December 30, 2009 Share Posted December 30, 2009 Still kind of new to mysql. I'm atm working on a project that I originally paid someone else to write for me, when I knew nothing. One thing I've noticed in the PHP scripts he wrote, is the use of mysql_close($db); near the end of every script which connects to the database. The tutorials I've been learning from so far haven't mentioned this function, but I'd hazard an educated guess that it closes the mysql connection. I'd like to ask, what exactly is the need/purpose for this? Is there a particular need to close connections? Does something happen if I don't? Will connections close themselves anyway after some timeout? Is there anything I haven't asked that I should know about connections? Thank you in advance for any replies. Quote Link to comment https://forums.phpfreaks.com/topic/186660-closing-connections/ Share on other sites More sharing options...
corbin Posted December 30, 2009 Share Posted December 30, 2009 Unless you have a script that will run for a long time and then won't use the database connection after a certain point in the script, you need not bother closing it. At the end of the script, PHP will automatically close any open resources. Quote Link to comment https://forums.phpfreaks.com/topic/186660-closing-connections/#findComment-985832 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.