title: mysql server has gone away - not timeout error or crash
body: <p>I'm using WAMP (Apache 2.2.11, MySQL 5.1.36, PHP 5.3.0) to write a PHP web application that has a link to a MySQL database.</p>
  
  <p>I run a procedure that takes about 2 minutes in Toad to execute. If i try to run it in the PHP application, i got the errors "MySQL server has gone away in...", "Error reading result set's header", and "maximum execution time of 60 seconds exceeded"</p>
  
  <p>I upped mysql.connect_timeout to 600 (using ini_set) and default_socket_timeout to 600 (as suggested in <a href="https://stackoverflow.com/questions/1644432/mysql-server-has-gone-away-in-exactly-60-seconds">this question</a>. This solved the timeout error, but i still get the first two.</p>
  
  <p>I tried setting max_input_time to -1, and on the MySQL server side, i upped max_allowed_packet to 256M. Neither of these solved the problem.</p>
  
  <p>Are there any other ways to bypass this error without altering the MySQL procedure being run?</p>
  
  <p>when the webpage is loaded:</p>
  
  <pre><code>set_time_limit(0);
  ini_set('mysql.connect_timeout', 600);//for long queries
  ini_set('default_socket_timeout', 600);//for long queries
  //ini_set('max_input_time',-1); //don't know what this does
  </code></pre>
  
  <p>when a query is called:</p>
  
  <pre><code>if($reconnect===true){
    $this-&gt;disconnectDB();
  }
  $this-&gt;connectToDB();
  if($this-&gt;selectDB($dbName)===FALSE){
    return false;
  }
  if(mysql_ping($this-&gt;con)===false){
    return array();           
  }
  $result = mysql_query($query,$this-&gt;con); //this is where the connection "goes away"
  </code></pre>