gingerboy101 Posted December 16, 2006 Share Posted December 16, 2006 Hi all,I am trying to get my head around what is the best, cleanest and most secure why to connect to a MySql data base.In short I followed the Membership system tutorial, in the tutorial you create a single file 'db.php' which holds the connection. However when I check the server it is leaving the connection open in some cases for 20,000 plus second and then creates more connections etc, the problem builds to a large number of connections which I have to go and kill.It seems when reading through various posts on the forum, that in many cases new connections are created in each page and they are also not persistent connections, so I have modified the 'db.php' to use non persistent connections and also added the mysql_close() command at the end of each page but they still seem to remain open. I have also amended the php.ini file to time connections out after 60 seconds but this has had no effect, and set the my.ini file for MySql to do the same but the same results.Am I best therefore to as in many posts create a new connection for each page?? I hope that this make sence and I dare say that I have answered my own question but some confirmation and clartity would be very help please.Cheers Quote Link to comment https://forums.phpfreaks.com/topic/30873-some-help-please-with-connections/ Share on other sites More sharing options...
Danny Beckett Posted December 16, 2006 Share Posted December 16, 2006 Presumably you're including the db.php file, simply use require_once("db.php"); instead of include("db.php"); and that should do it for you. Quote Link to comment https://forums.phpfreaks.com/topic/30873-some-help-please-with-connections/#findComment-142371 Share on other sites More sharing options...
gingerboy101 Posted December 16, 2006 Author Share Posted December 16, 2006 tried that, after looking at some simular questions, but it has still left the conection open.... Quote Link to comment https://forums.phpfreaks.com/topic/30873-some-help-please-with-connections/#findComment-142426 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.