matfish Posted March 20, 2009 Share Posted March 20, 2009 Hi, I've been redeveloping a website but every page I hit it creates a new Id in "Show Processlist" on the database. This being after viewing quite a few pages I then get the "Too many connections to database" error. I have dedicated server and connections are set to unlimited. This is obviously a coding issue. I require_once the connection.php script in the page header: global $config; global $db; $db = mysql_pconnect($config['db_hostname'], $config['db_user'], $config['db_password']); if (!$db){ //@ include($config['site_root']."errors/500.php"); echo "error: ".mysql_error(); exit; } global $db_name; $db_name = $config['db_database']; $db_select = mysql_select_db($db_name); Do I have to mysql_close($result) after every query? Still doesnt seem to help. Any ideas? Many thanks Quote Link to comment Share on other sites More sharing options...
matfish Posted March 20, 2009 Author Share Posted March 20, 2009 When I update the Show Process List the time just keeps going up, its not closing any connections even though I close them at the end of the query? Full Texts Id User Host db Command Time State Info Kill 989 website localhost DATABASE Sleep 36 NULL Kill 998 website localhost DATABASE Sleep 7 NULL Kill 999 website localhost DATABASE Sleep 4 NULL Kill 1000 website localhost DATABASE Sleep 4 NULL Kill 1001 website localhost DATABASE Sleep 4 NULL Kill 1010 website localhost DATABASE Query 0 NULL SHOW PROCESSLIST Quote Link to comment Share on other sites More sharing options...
matfish Posted March 20, 2009 Author Share Posted March 20, 2009 I'ce changed the code to mysql_connect and now I do not seem to have a problem. I thought it was best to use pconnect? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 20, 2009 Share Posted March 20, 2009 As you can see it isn't. pconnect in mysql extension is flawed. In PHP5.3 mysqli_pconnect is to be introduced which supposedly works better. Quote Link to comment Share on other sites More sharing options...
matfish Posted March 23, 2009 Author Share Posted March 23, 2009 Hi thanks for the reply. On another server I'm running PHP 5.1.6 with MySQLi (and using mysqli_pconnect) and only recently we are having the same "Too many connections" issue. Is there any way of finding out which script/page is causing such issues? Many thanks Quote Link to comment 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.