FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Too many connections error





welshsteve
Hi everyone,

Intermittently users of one of my site are getting:

Warning: mysql_connect(): Too many connections etc etc

I have checked all the pages on the site that connect to mysql, and every single one of them has a mysql_close() statement at the end of the script.

This is what I do to connect.

Code:

$con = mysql_connect("server_address_here","username_here","password_here");
if (!$con)
  {
  die('Could not connect: ' . mysql_error() . '<br /><br />Please contact the website administrator');
  }
mysql_select_db("database_name_here", $con);


At the bottom of every script is the following line

Code:

mysql_close($con);


I'm on shared hosting, which from my initial "googling" suggests this is something only the hosting provider can remedy. It can be caused by server issues, hardware issues, or other people's sites. I can't find a single page on my site that doesn't close connections using the above script. And I'm not using persistent connections so this isn't the issue.

Is anybody able to explain if there's anything I can do? Or should I contact the hosting providers? This is a site I don't host here, it's hosted with 1&1 internet, who are slow at responding so I'd rather not need to contact them if possible Rolling Eyes
D'Artagnan
you could use a persistent connection

http://php.net/manual/en/function.mysql-pconnect.php
http://php.net/manual/en/mysqli.construct.php
http://php.net/manual/en/pdo.connections.php
RosenCruz
I believe your site is getting popular and you might consider to upgrade to VPS hosting. On a shared hosting environments, mySQL server is handling all requests from all accounts. Which might be too much for the server.

On a shared hosting environments, there are limitations on mysql for an instance
welshsteve
I'm considering a new host anyway. Will see how it goes.
Related topics
Slight Server Problem
heu.. is it normal???
The connection was reset
TCP/IP connection exceeded
No more connection can be made .
The newest free domain site :D its mine :D
MySQL and DA problems on server 2
Too many connections.
ESSBase Data Integration Console ERROR 1042006
Server 2 Super High Load and DNS down
Recent downtime...?
#1040 - Too many connections
Problems with Mysql
1040 -Too many connections
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.