Page 1 of 1

Closing Connection

Posted: Thu Jun 14, 2012 1:45 pm
by alexrules01
Learning PHP in a class I'm in, I first learnt about closing a database connection (eg. mysqli_close() ).
So I have been using it thoughout most of my pages (the ones that contain PHP anyways) and I wanted to ask, is it necessary to close a connection?
I know Halls in his tutorials never closed them and doing a slight google search, I have read a connection closes at the end of a script anyways. Just curious to see if there is a main reason of closing a mysql connection, is it to open another?

I ask this, as I'm thinking should I bother putting the close connection at the bottom of every script. :lol:

Re: Closing Connection

Posted: Thu Jun 14, 2012 1:46 pm
by Chris

Re: Closing Connection

Posted: Thu Jun 14, 2012 6:55 pm
by Jackolantern
Basically, if you finish with MySQL a few lines above the end of the script, it really isn't important, although some people like to do it for clarify's sake. If you have a lot of processing to do, then you should close it.