PHP: MySQL server has gone away

后端 未结 3 1725
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 06:04

I know this question has been asked numerous times but I\'ve tried everything.

I have a PHP script that iterates through thousands of images, performs resizing if ne

相关标签:
3条回答
  • 2020-12-10 06:39

    you can use mysql_ping() to see if the connection still connected, if not you can try to reconnnect, or make an error message telling you how far the script had gone before the connection was lost.

    0 讨论(0)
  • 2020-12-10 06:40

    This happens because the PHP script took too long to process whatever it was processing, and the connection to the server timed out. You have a few solutions:

    • Check to make sure the connection is still up, and reconnect if needed (mysql_connect has built-in functionality to do that for you)
    • Use mysql_pconnect (but remember to close the connection at the end because it won't close for you)
    • Improve the running time of your script to avoid the timeout.
    0 讨论(0)
  • 2020-12-10 06:50

    Check the value of "max_allowed_packet" in your my.cnf MySQL config file.

    0 讨论(0)
提交回复
热议问题