max_connections error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leonardobii
Forum Newbie
Posts: 17
Joined: Fri Sep 02, 2005 8:47 pm

max_connections error

Post by leonardobii »

Recently, I have been getting the following error

Fatal error: User 'dhf' has exceeded the 'max_connections' resource (current value: 7200)

cant figure it out, can somebody help me out?
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

Whoa... That doesn't look too good.

max_connections is the value set for how may mysql connections can be made. Is this on a shared hosting environment? Current value of 7200 is alot. MySQL defaults at 150. If this is the case, you may be on a over worked box. You may also want to add addiitional error handling around your mysql_connect to not show error messages. Showing the username to a potential attacker may not be a good thing. I would wrap your mysql_connect() call with an 'if' and die().

Code: Select all

if(!$connect = mysql_connect($DBserver, $DBuser, $DBpassword)){
die("Database Connection Error");
}
If this is not a shared hosting environment, but your dedicated server.. I would check to make sure you're not a victim of a DoS.. since that is a lot of connections to allow at a given moment.

Hope this helps
hanji
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

hanji wrote:

Code: Select all

if(!$connect = mysql_connect($DBserver, $DBuser, $DBpassword)){
die("Database Connection Error");
}
Forget it! Don't be nice to those wankers, do it the manly way (ie: use brute force until you get what you want):

Code: Select all

while(!$connect = @mysql_connect($DBserver, $DBuser, $DBpassword)) { usleep(10000); }
That'll keep going until you get your damn connection. Yarrr!
leonardobii
Forum Newbie
Posts: 17
Joined: Fri Sep 02, 2005 8:47 pm

Post by leonardobii »

thanks, i appreciate the help
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

foobar wrote:
hanji wrote:

Code: Select all

if(!$connect = mysql_connect($DBserver, $DBuser, $DBpassword)){
die("Database Connection Error");
}
Forget it! Don't be nice to those wankers, do it the manly way (ie: use brute force until you get what you want):

Code: Select all

while(!$connect = @mysql_connect($DBserver, $DBuser, $DBpassword)) { usleep(10000); }
That'll keep going until you get your damn connection. Yarrr!

foobar... I like it!

hanji
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

hanji wrote: foobar... I like it!

hanji
Ye can always rely on ye ole bucaneer. Yarrr... :wink:
Post Reply