我有一个小门户网站,每天有7-8000个访问者,我做所有的SQL查询和编码。
我发现有时网站无法连接到数据库,而是显示消息“无法连接到mysql.”的5-10秒。这是mysql_connect error,15秒后一切恢复正常几个小时。没有登录更改,没有托管问题。我把mysql_close()放在网站的页脚上,但问题仍然存在。
造成这种错误的原因是什么?我应该在哪里找出问题并加以解决?它会不会也是与许多连接的网页?
发布于 2012-02-20 15:06:09
我只能给你一些一般性的建议,但我希望它们能帮上忙:
cannot connect to mysql...什么都没有。这听起来像是在"database_conection.php“有一些代码,在连接错误时显式地打印这样的消息。PHP默认错误往往更冗长,包括错误代码、文件名、行号.- Test the return value of the function.
- On error, call [mysql\_error()](http://php.net/mysql_error) to obtain the exact error message will all the details.
- Log all the details you need to identify the piece of code that triggered the error. For instance, [debug\_backtrace()](http://php.net/debug_backtrace) can tell you the precise function call chain.
https://stackoverflow.com/questions/9360724
复制相似问题