title: mysql: can't set max_allowed_package to anything grater than 16MB
body: <p>I'm not sure if this is the right place to post these kind of questions, if it's not so, please (politely) let me know... :-)</p>
  
  <p>I need to save files greater than 16MB on a mysql database from a php site...</p>
  
  <p>I've already changed the c:\xampp\mysql\bin\my.cnf</p>
  
  <p>and set max_allowed_packet to 16 MB, and everything worked fine</p>
  
  <p>then I set it to 32 MB but there´s no way I can handle a file bigger than 16 MB</p>
  
  <p>I get the following error:</p>
  
  <p>'MySQL server has gone away'</p>
  
  <p>(the same error I had when max_allowed_packet was set to 1MB)</p>
  
  <p>there must be some other setting that doesn´t allow me to handle files bigger than 16MB</p>
  
  <p>maybe the php client, I guess, but I don't know where to edit it</p>
  
  <p>this is the code I'm running</p>
  
  <p>when file.txt is smaller than 16.776.192 bytes long, it works fine, but</p>
  
  <p>if file.txt has 16.777.216 bytes i get the aforementioned error</p>
  
  <p>oh, and the field download.content is a longblob...</p>
  
  <pre><code>
  
  $file = 'file.txt';
  
  $file_handle = fopen( $file, 'r' );
  
  $content = fread( $file_handle, filesize( $file ) );
  
  fclose( $file_handle );
  
  db_execute( 'truncate table download', true );
  
  $sql = 
  "insert into download( 
      code, title, name, description, original_name, 
      mime_type, size, content, 
      user_insert_id, date_insert, user_update_id, date_update )
  values (
      'new file', 'new file', 'sas.jpg', 'new file', '$file',
      'mime', " . filesize( $file ) . ", '" . addslashes( $content ) . "',
      0, " . db_char_to_sql( now_char(), 'datetime' ) . ", 0, " . db_char_to_sql( now_char(), 'datetime' ) . " )";
  
  db_execute( $sql, true );
  
  </code></pre>
  
  <p>(the db_execute funcion just opens the connections and executes the sql stuff)</p>
  
  <p>running on windows XP sp2
  server version: 5.0.67-community
  PHP Version 4.4.9
  mysql client API version:   3.23.49 </p>
  
  <p>using:  ApacheFriends XAMPP (Basispaket) version 1.6.8
  that comes with
    + Apache 2.2.9
    + MySQL 5.0.67 (Community Server)
    + PHP 5.2.6 + PHP 4.4.9 + PEAR
    + phpMyAdmin 2.11.9.2
  ...</p>
  
  <p>this is part of the content of 
  c:\xampp\mysql\bin\my.cnf</p>
  
  <pre>
  # The MySQL server
  [mysqld]
  port= 3306
  socket= "C:/xampp/mysql/mysql.sock"
  basedir="C:/xampp/mysql" 
  tmpdir="C:/xampp/tmp" 
  datadir="C:/xampp/mysql/data"
  skip-locking
  key_buffer = 16M
  # max_allowed_packet = 1M
  max_allowed_packet = 32M
  table_cache = 128
  sort_buffer_size = 512K
  net_buffer_length = 8K
  read_buffer_size = 256K
  read_rnd_buffer_size = 512K
  myisam_sort_buffer_size = 8M
  </pre>