php, mysql - Too many connections to database error
There are a bunch of different reasons for the "Too Many Connections" error.
Check out this FAQ page on MySQL.com: http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html
Check your my.cnf file for "max_connections". If none exist try:
[mysqld]
set-variable=max_connections=250
However the default is 151, so you should be okay.
If you are on a shared host, it might be that other users are taking up too many connections.
Other problems to look out for is the use of persistent connections and running out of diskspace.
The error SQLSTATE[HY000] [1040] Too many connections
is an SQL error, and has to do with the sql server. There could be other applications connecting to the server. The server has a maximum available connections number.
If you have phpmyadmin, you can use the 'variables' tab to check what the setting is.
You can also query the status table like so:
show status like '%onn%';
Or some variance on that. check the manual for what variables there are
(be aware, 'connections' is not the current connections, check that link :) )