Lately I've been having troubles with my mySQL databases. I include the page http://thunder3.cwihosting.com/~super/connectinc.php3 on all of my pages using the require() function to connect to my database. Lately though, whenever I go to my site, it gives me errors like this:
Warning: MySQL Connection Failed: Too many connections in /home/super/public_html/connectinc.php3 on line 2
Since all of my content is in mySQL, these errors make my site useless, so I need to get the problem fixed as soon as possible. Are these problems likely my host's fault, or am I just getting too many visitors for my site to handle?(I get about 1,300 uniques per day and about 20,000 page views per day)
Hello,
I'm not sure, but do you use mysql_pconnect? According to Luke Welling and Laura Thomson, authors of the book "PHP and MySQL Web Development", when you use mysql_pconnect, "This saves time and server overhead".
You should try and use persistent connections - mysql_pconnect() Check your php configeration - php_info() - to see whether persistent connections are turned on. Some shared hosts will turn persistent connections off because it ties up connections (which is good for you, but bad for the host if they are trying to serve lots of virtual accounts with the one mysql server). Your mysql server may not even be on the same server as your web site. So, the problem could be that the web host is serving too many sites with the one mysql server. You should contact your host and see if they can improve matters for you. I think this is one of the real frustrations of using shared hosting.
Bookmarks