Welcome to WebmasterWorld Guest from 184.108.40.206 , register , login , search , subscribe , help , library , PubCon , announcements , recent posts , open posts Accredited PayPal World Seller
When (where) to mysqli close($mysqli); rigaconnect msg:4542891 9:34 am on Feb 6, 2013 (gmt 0) I need to validate username if it already exists in database. I connect to database, validate. Then other php code Then again I need to validate email if it already exists in database. Is it necessary to close connection after each query? mysqli_close($mysqli); Or I can close one time at bottom of file when I know that latter would not be necessary to connect to database. I mean for security reasons. If i close at bottom of file, are there exist some security problems?
whoisgregg msg:4544614 5:41 pm on Feb 11, 2013 (gmt 0)
Opening a connection is an expensive operation. You should only close the connection when you are sure it won't be used again. However, open connections are automatically destroyed at the end of script resolution. So, although calling mysqli_close() will free up those memory resources for the rest of the script, it's not actually a requirement to call that function at all. rigaconnect msg:4544631 6:02 pm on Feb 11, 2013 (gmt 0)