Too Many Connections Error Mysql/php

admin

Administrator
Staff member
I have a form that a client uses to add records to a database.<br /><br />The php connection code is:<br /><br />$boxingdayrun = mysql_pconnect($hostname_dbname, $username_somename, $password_somepassword) or die(mysql_error());<br /><br />So a client is using the form to add about 40 records however we are getting errors now that states<br /><br />Warning: mysql_pconnect() [function.mysql-pconnect]: User online_bob has already more than 'max_user_connections' active connections in /.........../form.php on line 10<br />User online_bob has already more than 'max_user_connections' active connections<br /><br />I have been using this code for a couple years without any problems. Is there something else I can use so that each time the form is used, it will work without the error?<br /><br />Thanks<!--content-->
Hi Wayne, <br /><br />Try changing from pconnect to connect. <br /><br />Whilst persistent connections eleminate the overheads during creation of new connections, mysql takes relatively short time for creating new connections and often the benefit of using persistent connections is not noticeable. Also, considering the drawbacks of using persistent connections its advantages are negligible. You may have also have to check your code and verify that all mysql sesstions are getting closed after the script execution.<!--content-->
Thanks Andy<br /><br />I have this at the bottom of the page, is this what you mean?<br /><br /><?php<br />mysql_free_result($Recordset1);<br />?><br /><br />My understanding (limited) was that this closed the session so I should not have this problem.<!--content-->
OK did some research and have added<br />mysql_close();<br /><br />to the bottom of my pages, hope this solves the problem<!--content-->
You chould really mysql_close($db); at the end - not just free the result memory with mysql_free_result(); I don't think the mysql_free_result would not close the connection when using pconnect.<!--content-->
You beat me to it <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /><!--content-->
Well my problem re-appeared today. Confusing since I only have two forms up at the moment while most of the year I have about 20 going at once and have never had this problem before. Help desk has told me to make sure I am closing my db sessions and not using persistent connections.<br /><br />Here is the code I am using. Would appreciate if someone can have a look to see if I am overlooking something.<br /><br />$hostname_mydbconnection = "localhost";<br />$database_mydbconnection = "xxxxxxxxx";<br />$username_mydbconnection = "xxxxxxx";<br />$password_mydbconnection = "xxxxxxx";<br /><br />$mydbconnection = mysql_connect($hostname_mydbconnection , $username_mydbconnection , $password_mydbconnection ) or die(mysql_error());<br /><br /><br />bunch of code that reads, inserts data to the database<br /><br />At the end of the page I have:<br /><?php<br />mysql_free_result($Recordset1);<br />mysql_close($mydbconnection );<br />?><br /><br /><br />**************<br />So I thought that this should end the connection and that this page can be reloaded as often as necessary without problems. <br />Am I missing something?<br />Help desk did say that they have reset the mysql connections however not sure if this will happen again.<br />When it does, all my forms stop working.<br /><br />Thanks<!--content-->
Well my problem just came back.<br />Currently I have only about 4 pages using the same user,whereas for the last few years I have had 80+ and have never had this error.<br /><br />I am suspecting that something is certainly wrong with some settings.<br /><br />Anyone else run into this problem?<br />I am on server 365<br /><br />i have submitted another help desk ticket but wondered if the community at large could offer any insights.<!--content-->
Wayne, please open a ticket with the help desk if you feel it is a server setting.<!--content-->
 
Top