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 Link to comment https://forums.phpfreaks.com/topic/150326-unusual-too-many-pconnect-connections/ 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 Link to comment https://forums.phpfreaks.com/topic/150326-unusual-too-many-pconnect-connections/#findComment-789491 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? Link to comment https://forums.phpfreaks.com/topic/150326-unusual-too-many-pconnect-connections/#findComment-789502 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. Link to comment https://forums.phpfreaks.com/topic/150326-unusual-too-many-pconnect-connections/#findComment-789553 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 Link to comment https://forums.phpfreaks.com/topic/150326-unusual-too-many-pconnect-connections/#findComment-791629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.