0

Possible Duplicate:
Is closing the mysql connection important?

Edit - the above is not the same question and does not answer my question here. Here I speak specifically about the case that you DONT issue a query on the opened connection and I further ask what governs this closing, neither of which are addressed in the above answer.

If you use mysql_connect to connect to a database then don't issue a query on the database for a couple minutes, is the connection automatically closed? And if so, what governs this closing?

Thanks

Community
  • 1
  • 1
iss42
  • 2,720
  • 3
  • 21
  • 37
  • 2
    The connection will close after a certain amount of time. [**Don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](http://j.mp/XqV7Lp). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which – Kermit Jan 25 '13 at 22:57
  • Thanks, this is an old project I am maintaining, but I note your suggestion. – iss42 Feb 13 '13 at 17:06

1 Answers1

0

Yes, the connection will be closed at the end of the script.

From php.net

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

Fr0z3n
  • 1,569
  • 1
  • 18
  • 39
  • My connection is being closed before the end of the script and before any query is issued on it. – iss42 Feb 13 '13 at 13:29