Error: "MySQL server has gone away"
Posted on 2010-11-14
I have written a bit of PHP script to query a DB and loop through 1200+ rows and build a couple multidimensional arrays. The trouble is that the queries & loops etc take so long that it appears the server connection closes.
When I lower the loop count limit to 3 or for instead of 1200 I don't get any errors and everything is great. So it seems to be related to the time it takes to complete the script.
It's a godaddy MySQL server so I doubt that I have control over reconnect & timeout parameters. Is there anything in the script I can do to hold the connection open or should I open and close the connection with every loop iteration?
I am getting this error later in the script when I try an insert after the big time consuming loop: MySQL server has gone away.