Ok, i got this script i run on my server, this script runs exactly 47 secs or so (45 to 49) each time i run it. I run it from the command line cause it's going to be a CRON job i'll run every month.
My question is, why after 47 seconds or so does my script end saying: <b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>/var/www/autoexpert/includes/db.php</b> on line <b>69</b><br> This sucks, i did another script that imports data, it takes something like 5 minutes to execute, and it's pretty much the same code, why does this one end like that with a fatal error while the other goes trough its very long task of import a whole set of data in 5 minutes. I'd like to know exactly how PHP calculates that my script ran too much time. Here is the code in case you need to see it. Please do not fix my code for me, if there are bugs i will find them, i just want to know how PHP says it's been 30 seconds. Mathieu Dumoulin Web Solutions Programmer Analyst Code: #! /usr/bin/php <?php /*This file is used each month on the 1st day to compile the whole previous month data for the cars and for the person to which this post pertains to.*/ //Definition define('IN_INDEX', 1); //Connect to the database include("../includes/config.php"); include("../includes/db.php"); //Open the connection $db->connect(); //Get the current date //$curDate = date("Y-m-d"); $curDate = "2003-03-01"; //Get the previous month's complete date $cur_expl = explode("-", $curDate); $cur_month = $cur_expl[1]; if($cur_month == 1){ $prev_month = 12; $prev_year = $cur_expl[0] - 1; }else{ $prev_month = $cur_month - 1; $prev_year = $cur_expl[0]; } $prev_day = "01"; $prevDate = (string)$prev_year . "-" . @str_repeat("0", 2 - strlen($prev_month)) . $prev_month . "-" . $prev_day; $prevDateYearOnly = (string)$prev_year . "-" . "01" . "-" . $prev_day; //Echo echo "Running... please wait\n"; //Get all this month's stats $db->query("SELECT * FROM stats_vehicules_days WHERE day >= '$prevDate' AND day < '$curDate' ORDER BY vehiculeid", "stats_vehicules_days"); //Loop and add all lines as needed while($row = $db->fetch_array("stats_vehicules_days")){ //Update the line in the stats_vehicules_month $db->query("UPDATE stats_vehicules_months SET clicks = clicks + " . $row[clicks] . ", views = views + " . $row[views] . " WHERE vehiculeid = " . $row[vehiculeid] . " AND month = '$prevDate'", "updateStats"); //Get the Info ID for this vehicule $db->query("SELECT i.id AS info_id FROM info AS i, annonces AS a, vehicules AS v WHERE i.id = a.infoid AND a.id = v.annonceid AND v.id = " . (string)$row[vehiculeid], "infoId"); $infoid_row = $db->fetch_array("infoId"); //Write the stats for this user $db->query("UPDATE stats_info_months SET clicks = clicks + " . $row[clicks] . ", views = views + " . $row[views] . " WHERE infoid = " . $infoid_row[info_id] . " AND month = '$prevDate'", "updateStats"); $db->query("UPDATE stats_info_years SET clicks = clicks + " . $row[clicks] . ", views = views + " . $row[views] . " WHERE infoid = " . $infoid_row[info_id] . " AND year = '$prevDateYearOnly'", "updateStats"); } //Close the connection $db->close(); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php