doubledee Posted March 16, 2012 Share Posted March 16, 2012 When you open a database connection, how long does it stay open for? I have a "Change E-mail Address" script that has 4 queries in it, and I just realized that I don't create a DB Connection until Query #2 in my script, yet things work fine?! Is it possible that the DB Connection was opened earlier by another script and it is just persisting?? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/259067-life-of-database-connection/ Share on other sites More sharing options...
guinbRo Posted March 16, 2012 Share Posted March 16, 2012 The connection should close automatically if not specifically closed before hand at the end of a script execution. If you call it earlier in your code, and don't close it, it would stay open even if it was in a file you are including. Quote Link to comment https://forums.phpfreaks.com/topic/259067-life-of-database-connection/#findComment-1328130 Share on other sites More sharing options...
scootstah Posted March 16, 2012 Share Posted March 16, 2012 I think you are opening a connection and you just don't realize it. You can't run queries without a connection. Quote Link to comment https://forums.phpfreaks.com/topic/259067-life-of-database-connection/#findComment-1328131 Share on other sites More sharing options...
doubledee Posted March 16, 2012 Author Share Posted March 16, 2012 I think you are opening a connection and you just don't realize it. You can't run queries without a connection. You are correct. I had it in my "last_activity.php" file which I included in my "change_email.php" script. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/259067-life-of-database-connection/#findComment-1328190 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.