title: PHP scripts execute stops after a while with no error report
body: <p>i have a crawler script that run 4 bots Simultaneously,
  each bot is opened in a new tab and generally does that:</p>
  
  <p>1/ connection to db + set vars that are needed for the scraping.<br />
  2/ takes a URL target from db.<br />
  3/ get the content using CURL OR file_get_content.<br />
  4/ set the "$html" with simple_html_dom.<br />
  5/ include an "engine" that scrapes and manipulate the content.<br />
  6/ finally - check if its OK and optimize the content and store it in the db<br />
  7/ do it for X links. after the X links will refresh the page and continue the crawling process.<br /><br /></p>
  
  <p>every thing worked like magic! but lately after a few minutes (not the same time) all the bots are <br />stopped (with no errors flashed) some times only 3 of them... <br />
  there is a script that set time interval that refresh the page every Y minutes. that is keepig my<br /> bots working if they are jammed but its not an answer for this problem.<br /></p>
  
  <p>i have checked the apache error log and its not indicating anything strange.<br />
  <br />
  do you have any idea???<br />
  shrink code: (with comments)</p>
  
  <pre><code>ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5');
  error_reporting(E_ALL);
  include ("peulot/stations1.php");//with connection and vars
  include_once('simple_html_dom.php');
  
  //DEFINE VALUES:
  /*
  here vars are declared and set
  */
  
          echo "
              &lt;script language=javascript&gt;
  
              var int=self.setInterval(function(){ refresh2(); },".$protect.");
  
              var counter;
  
              function refresh2() { 
                  geti();
                  link = 'store_url_beta.php?limit_link=".$limit_link."&amp;storage_much=".$dowhile."&amp;jammed=".($jammed_count+=1)."&amp;bot=".$sbot."&amp;counter=';
                  link = link+counter;
                  window.location=link;
                  } 
  
              function changecolor(answer)
                      {
                  document.getElementById(answer).style.backgroundColor = \"#00FF00\";
                      }
              &lt;/script&gt;";//this is the refresh if jammed
  
  
  //some functions:
  /*
  function utf8_encode_deep --&gt; for encoding
  function hexbin --&gt; for simhash fingerprint
  function Charikar_SimHash --&gt; for simhash fingerprint
  function SimHashfingerprint --&gt; for simhash fingerprint
  */              
  
          while ($i&lt;=$dowhile)
              {
  
              //final values after crawling:
              $link_insert="";
              $p_ele_insert="";
              $title_insert="";
              $alt_insert="";
              $h_insert="";
              $charset="";
              $text="";
              $result_key="";
              $result_desc="";
              $note="";
  
              ///this connection is to check that there are links to crawl in data base... + grab the line for crawl.
              $sql = "SELECT * FROM $table2 WHERE crawl='notyet' AND flag_avoid $regex $bot_action";
              $rs_result = mysql_query ($sql); 
              $idr = mysql_fetch_array($rs_result);                           
              unset ($sql);
              unset ($rs_result);
  
                set_time_limit(0);
  
                $qwe++;
  
                      $target_url = $idr['live_link'];//set the link we are about to crawl now.
                      $matches_relate = $idr['relate'];//to insert at last
                      $linkid = $idr['id'];//link id to mark it as crawled in the end
                      $crawl_status = $idr['crawl'];//saving this to check if we update storage table or insert new row
                      $bybot_status = $idr['by_bot'];//saving this to check if we update storage table or insert new row
  
                      $status ="UPDATE $table2 SET crawl='working', by_bot='".$bot."', flag_avoid='$stat' WHERE id='$linkid'";
                      if(!mysql_query($status)) die('problem15');                 
  
                      $ch = curl_init(); 
  
                      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'); 
                      curl_setopt($ch, CURLOPT_URL, $target_url); 
                      curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
                      curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
                      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
                      curl_setopt($ch, CURLOPT_HEADER, 0); 
                      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  
                      $str = curl_exec($ch); 
                      curl_close($ch);
  
                      if (strlen($str)&lt;100) 
                              {
                              //do it with file get content
                              }               
          if (strlen($html)&gt;500)
          {
  
                              require("engine.php");//GENERATE FATAL ERROR IF CRAWLER ENGINE AND PARSER NOT AVAILABLE
  
                          flush();//that will flush a result without any refresh
                          usleep(300);                                
  
                                  //before inserting into table storage check if it was crawled before and then decide if to insert or update:
                                  if ($crawl_status=="notyet"&amp;&amp;$bybot_status=="notstored")
                                              {
                                              //insert values
                                              }
                                              else
                                              {
                                              //update values
                                              }
  
                          flush();//that will flush a result without any refresh
                          usleep(300);
  
  
                          if ($qwe&gt;=$refresh) //for page refresh call
                              { 
                              $secounter++;//counter for session
                              //optimize data                         
                              echo "&lt;script type='text/javascript'&gt;function refresh() { window.location='store_url_beta.php?limit_link=".$limit_link."&amp;counter=".$i."&amp;secounter=".$secounter."&amp;storage_much=".$dowhile."&amp;jammed=".$jammed."&amp;bot=".$sbot."'; } refresh(); &lt;/script&gt;";                          
                              }
              }//end of if html is no empty.
              else
              {//mark a flag @4 and write title jammed!
  
              //here - will update the table and note that its not possible to crawl
  
                          if ($qwe&gt;=$refresh) 
                              { 
                              $secounter++;//counter for session
                              //optimize data                         
                              echo "&lt;script type='text/javascript'&gt;function refresh() { window.location='store_url_beta.php?limit_link=".$limit_link."&amp;counter=".$i."&amp;secounter=".$secounter."&amp;storage_much=".$dowhile."&amp;jammed=".$jammed."&amp;bot=".$sbot."'; } refresh(); &lt;/script&gt;";                          
  
                              }
              }//end of else cant grab nothing
              unset($html);
          }//end of do while
              mysql_close(); 
              echo "&lt;script language=javascript&gt; window.clearInterval(int); &lt;/script&gt;";
  </code></pre>
  
  <p><strong>Edit:</strong><br />
  after endless testing and logging methods (following jack advice) i found nothing! 
  the only thing that happens when the bots are stopped is in the apache log:</p>
  
  <pre><code> [Thu Oct 25 01:01:33 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
   zend_mm_heap corrupted
   [Thu Oct 25 01:01:51 2012] [notice] Parent: child process exited with status 1 -- Restarting.
   [Thu Oct 25 01:01:51 2012] [notice] Apache/2.2.22 (Win64) mod_ssl/2.2.22 OpenSSL/1.0.1c PHP/5.3.13 configured -- resuming normal operations
   [Thu Oct 25 01:01:51 2012] [notice] Server built: May 13 2012 19:41:17
   [Thu Oct 25 01:01:51 2012] [notice] Parent: Created child process 736
   [Thu Oct 25 01:01:51 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
   [Thu Oct 25 01:01:51 2012] [notice] Child 736: Child process is running
   [Thu Oct 25 01:01:51 2012] [notice] Child 736: Acquired the start mutex.
   [Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting 200 worker threads.
   [Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting thread to listen on port 80.
   [Thu Oct 25 01:01:51 2012] [notice] Child 736: Starting thread to listen on port 80.
   [Thu Oct 25 01:01:51 2012] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
  </code></pre>
  
  <p><strong>this line is mysterious i really dont know what to do please help me!</strong> <br />
       [Thu Oct 25 01:01:51 2012] [notice] Parent: child process exited with status 1 -- Restarting.</p>