Closing Connection

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
alexrules01
Posts: 175
Joined: Sun Oct 11, 2009 9:33 am

Closing Connection

Post 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:
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: Closing Connection

Post by Chris »

Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Closing Connection

Post 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.
The indelible lord of tl;dr
Post Reply

Return to “Beginner Help and Support”