title: PHP: MySQL server has gone away
body: <p>I know this question has been asked numerous times but I've tried everything.</p>
  
  <p>I have a PHP script that iterates through thousands of images, performs resizing if necessary and then inserts into the database.</p>
  
  <p>I'm getting this error message:</p>
  
  <blockquote>
    <p>Warning: mysql_query() [function.mysql-query]: MySQL server has gone
    away in C:\Utilities\server\htdocs\newGen\index.php on line 105</p>
    
    <p>Warning: mysql_query() [function.mysql-query]: Error reading result
    set's header in C:\Utilities\server\htdocs\newGen\index.php on line
    105</p>
  </blockquote>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>All help is greatly appreciated, I've been going at this for hours now.</p>
  
  <p>EDIT:</p>
  
  <p>Here is the code at the 105 mark, it's the query:</p>
  
  <pre><code>        // Add tNail and image to db
          mysql_query("INSERT INTO gallery values('','$hash','$thumbBlob','$imageBlob','$type','','0','0.0')");
      //  $q-&gt;execute();
          print "Successfully processed $fileName&lt;br&gt;";
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>