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 necessary and then inserts into the database.
I'm getting this error message:
Warning: mysql_query() [function.mysql-query]: MySQL server has gone away in C:\Utilities\server\htdocs\newGen\index.php on line 105
Warning: mysql_query() [function.mysql-query]: Error reading result set's header in C:\Utilities\server\htdocs\newGen\index.php on line 105
I'm using Xampplite and so some parts of the php.ini are missing that others have used to solve the problem because they're not using the lite version.
I'm certain the problem is not timeouts. While the script will run for several minutes it skips over images that have already been processed and so I quickly get the error message within about 10 seconds. Maybe this has something to do with max table size? I can't find anything in my php.ini that controls this.
All help is greatly appreciated, I've been going at this for hours now.
EDIT:
Here is the code at the 105 mark, it's the query:
// Add tNail and image to db
mysql_query("INSERT INTO gallery values('','$hash','$thumbBlob','$imageBlob','$type','','0','0.0')");
// $q->execute();
print "Successfully processed $fileName<br>";
As you can see by the comments I tried PDO with this and got the same error, foolishly I thought going back to mysql_ commands would help.
If it's of any help the script complains at the same image every time, yet each image is only ever a few tens of kilobytes and a couple hundred at the most.
mysql_*
functions for new code. They are no longer maintained and the community has begun the deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide, this article will help to choose. If you care to learn, here is good PDO tutorial.