apache - php - "an error occurred while processing this directive" while calling fwrite more than 1000 times -
i have php script opens file in w mode , writes text using fwrite .
fwrite() used in loop , fwrite() should called 2000 times .
the script runing 15 minutes or , doesn't write data file , stops after ~900 loop . , after script ends error error occurred while processing directive .
by runing loop 300 times don't error , data writen file . can see after 900+ loop fwrite stop , error .
any ideea on how debug error ?
here code :
$handle = fopen("rankings_update_output.txt", "w"); $listings_updated = array('updated'=>array() , 'failed'=>array(), 'same_values'=>array()); foreach($result_array $obj) { $alexa_int = $alexa_ranking_class->get_rank($obj->prefix.$obj->redirect); $google_int = $google_ranking_class->get_google_pagerank($obj->prefix.$obj->redirect); $google_int = ($google_int == null || !is_int($google_int)) ? 0 : $google_int ; $alexa_int = ($alexa_int == null || !is_int($alexa_int)) ? 0 : $alexa_int ; $query = 'update listings set google_rank ='.$google_int.' , alexa_rank ='.$alexa_int.' id ='.$obj->id; if($mysqli->query($query)) { if($mysqli->affected_rows !== 0) { $listings_updated['updated'][] = $obj->id; fwrite($handle, 'listing update : '.$obj->id); } else { $listings_updated['same_values'][] = $obj->id; fwrite($handle, 'listing not update (same value) : '.$obj->id); } } else { $listings_updated['failed'][] = $obj->id; fwrite($handle, 'listing failed : '.$obj->id); } } $mysqli->close(); $final_output = 'listings updated ('.count($listings_updated['updated']).' - total ) : '; foreach($listings_updated['updated'] $val) { $final_output .= $val.' , '; } $final_output .= '<br /> <br /> \n\n listings not updated (same values) ('.count($listings_updated['same_values']).' - total ) : '; foreach($listings_updated['same_values'] $val) { $final_output .= $val.' , '; } $final_output .= '<br /> <br /> \n\n listings failed ('.count($listings_updated['failed']).' - total ) : '; foreach($listings_updated['failed'] $val) { $final_output .= $val.' , '; } fwrite($handle, $final_output); fclose($handle);
Comments
Post a Comment