Hi there
I've written the basics of a PHP driven calendar that allows you to create a recurring event. For example, I attempted to generate an event every Thursday for 3 months, to do this I call the PHP function "strtotime" (http://php.net/manual/en/function.strtotime.php) numerous times.
However, when I attempt this, I get a 500 Internal Server Error, and my error logs are reporting the following;
[Mon Aug 20 02:04:09 2007] [error] [client <<IP>>] FATAL: emalloc(): Unable to allocate 35 bytes
[Mon Aug 20 02:04:09 2007] [error] [client <<IP>>] Premature end of script headers: php4
The code in question is as follows;
$recur = array();
$week = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
$start = strtotime($_POST['date_year'].'-'.$_POST['date_month'].'-'.$_POST['date_day']);
$until = strtotime($_POST['until_year'].'-'.$_POST['until_month'].'-01');
$curr = $start;
while($curr<$until) {
$recur[] = $curr;
$curr = strtotime("next ".$week[$_POST['frequency_day']],$curr);
}
Or, with the POST's filled out for testing purposes;
<?php
// test emalloc bug
$recur = array();
$week = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
$start = strtotime('2007-09-07');
$until = strtotime('2007-12-01');
$curr = $start;
while($curr<$until) {
$recur[] = $curr;
$curr = strtotime("next ".$week[3],$curr);
}
print_r($recur);
?>
Surely there should be no issues calling a pretty stock standard PHP function several times - I mean for every Thursday for 3 months we're only talking around 15-20 times right? Thoughts?
Cheers
James