dongxinyue2817 2010-03-23 11:59
浏览 38
已采纳

php数据库连接错误

im hoping someone can help me quickly with a question i have.

As site i have build is occasionally returning with the error

Warning: mysqli::mysqli() [mysqli.mysqli]: (08004/1040): Too many connections in

Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in

Now at first i thought this was happening as i hadent closed the connection at the end of each page, now i get the connection like this at the beginning of a page / script

$conn = new mysqli($host, $username, $password, $database);

and at the very end call

$conn->close();

Also i close any result sets i have open.

Looking at my log files around the time i accessed the site today and saw this error, I accessed about 12 o clock and at first the page wouldnt even load, then it gave me this error. before that one person visted around 11:30 and then 10:30, not exactly heavy traffic.

The host I have gone with is very quiet and there is no way to get in contact with them, and ignoring any support emails, i thought maybe as now i hear they are not very good this could be an issue with a badly set up shared mysql server?

Any thoughts or suggestions would be amazing as i need to sort this out!

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dongsao8279 2010-03-23 12:05
    关注

    It sounds like the MySQL server is being shared by too many accounts, as that error means that the server's max_connections setting has been exceeded. It could be that there are several other high-traffic customers that are taking up the connections (this is a shared MySQL server, I take it?)

    I'm fairly sure that PHP automatically closes resources at the end of the request (although it's always best to explicitly close your connections etc. anyway) so I wouldn't think it's your script keeping connections open.

    You'll need to keep on at your hosting provider, I'm afraid, or consider moving providers. Also try to keep a log of when the errors occur and for how long, as you'll need that as evidence if they refuse to acknowledge there's a problem.

    You can also refer your provider to this page: http://dev.mysql.com/doc/refman/5.1/en/too-many-connections.html.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据