Jump to content

Too Many Connections Error Mysql/php


Recommended Posts

I have a form that a client uses to add records to a database.


The php connection code is:


$boxingdayrun = mysql_pconnect($hostname_dbname, $username_somename, $password_somepassword) or die(mysql_error());


So a client is using the form to add about 40 records however we are getting errors now that states


Warning: mysql_pconnect() [function.mysql-pconnect]: User online_bob has already more than 'max_user_connections' active connections in /.........../form.php on line 10

User online_bob has already more than 'max_user_connections' active connections


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?



Link to comment
Share on other sites

Hi Wayne,


Try changing from pconnect to connect.


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.

Link to comment
Share on other sites

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.


Here is the code I am using. Would appreciate if someone can have a look to see if I am overlooking something.


$hostname_mydbconnection = "localhost";

$database_mydbconnection = "xxxxxxxxx";

$username_mydbconnection = "xxxxxxx";

$password_mydbconnection = "xxxxxxx";


$mydbconnection = mysql_connect($hostname_mydbconnection , $username_mydbconnection , $password_mydbconnection ) or die(mysql_error());



bunch of code that reads, inserts data to the database


At the end of the page I have:



mysql_close($mydbconnection );





So I thought that this should end the connection and that this page can be reloaded as often as necessary without problems.

Am I missing something?

Help desk did say that they have reset the mysql connections however not sure if this will happen again.

When it does, all my forms stop working.



Link to comment
Share on other sites

  • 3 weeks later...

Well my problem just came back.

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.


I am suspecting that something is certainly wrong with some settings.


Anyone else run into this problem?

I am on server 365


i have submitted another help desk ticket but wondered if the community at large could offer any insights.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...