Roy Barten Posted February 18, 2009 Share Posted February 18, 2009 Hello, i created the following code but get the following error message: <html> <head> <title></title> </head> <body> <table border="1" id="kalender" width="900" cellpadding="0" cellspacing="0"> <tr> <td width="20"></td> <td width="30">maandag</td> <td width="30">dinsdag</td> <td width="30">woensdag</td> <td width="30">donderdag</td> <td width="30">vrijdag</td> <td width="30">zaterdag</td> <td width="30">zondag</td> </tr> <? include ("array.php"); $calendartype = "week"; for($i = 0; $i <= 23; $i++) { echo "<tr height='20'><td width='20'>"; } for($i = 0; $i <= 23; $i++) { $number = $i; $date = ConvertToDateTime($number,$calendartype); foreach($array as $val) { $s_date = strtotime($val['start']); $e_date = strtotime($val['end']); $countres = 0; if($date > $s_date && $date < $e_date) //als de gekozen datum tussen de start en enddate ligt { $countres++; $hours = $e_date - $s_date; for($i=0; $i<=$countres; $i++) { $width = 30 / $countres; echo "<td width=$width rowspan=$hours"; } } } } function ConvertToDateTime($number,$calendartype) { if ($calendartype == "week"){ $time = date("$number:00:00 2009-03-02"); $date = strtotime($time); } if ($calendartype == "month"){ $day = date("00:00:00 2009-03-$number"); $date = strtotime($day); } return $date; } ?> </table> </body> </html> Fatal error: Maximum execution time of 60 seconds exceeded What do i wrong? Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/ Share on other sites More sharing options...
cola Posted February 18, 2009 Share Posted February 18, 2009 Try to use this command. 0 means that excution will never expired. set_time_limit(0); Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765039 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 Will not help much if the code goes into infinite loop somewhere. Check all loop conditions, and make sure that every loop ends eventually. Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765041 Share on other sites More sharing options...
Roy Barten Posted February 18, 2009 Author Share Posted February 18, 2009 I did, but everything looks fine. Now i tried something and i know that if i remove the following lines: $s_date = strtotime($val['start']); $e_date = strtotime($val['end']); the page shows up without any error, bit it does not work cause these variables are not converted. Waht's wrong about these lines? Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765047 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 strtotime is not really fast How many values are there in $array ? Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765050 Share on other sites More sharing options...
Roy Barten Posted February 18, 2009 Author Share Posted February 18, 2009 In this case 4, maybe 5 but not any more. Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765051 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 Oh... if you remove those two lines, then $s_date and $e_date are undefined, so if($date > $s_date && $date < $e_date) will never be true, and the code will not go into the last loop Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765056 Share on other sites More sharing options...
Roy Barten Posted February 18, 2009 Author Share Posted February 18, 2009 exactly and thats just the problem, i need these variables but how do i use this? Is there any other function instead of strtotime? Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765113 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 You don't see my point. The fact that you removed those two lines, prevented the code to go into this loop. This might indicate, that this loop might be responsible for your problem. Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765214 Share on other sites More sharing options...
premiso Posted February 18, 2009 Share Posted February 18, 2009 You do realize that you have a for ($i inside of a for $i, this i is being reset each time you loop through and thus sending you into an infinite loop. Change the inner $i to something different like $x and this should help, if not solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765230 Share on other sites More sharing options...
Mchl Posted February 18, 2009 Share Posted February 18, 2009 Good catch. That should do it. Quote Link to comment https://forums.phpfreaks.com/topic/145711-fatal-error-maximum-execution-time-of-60-seconds-exceeded/#findComment-765235 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.