erik_1099
Junior Member
Posts: 8
Registered: 3/28/2008
Location: Southern California
Member Is Offline
|
| posted on 4/10/2008 at 07:56 PM |
|
|
Months without events giving an error
For months without events, I am getting this error:
Warning: Invalid argument supplied for foreach() in /data/10/0/65/122/880611/user/901742/htdocs/calendar/cl_files/events.php on line 115
I am guessing the code just needs to be modified to deal with the case where there are no events for the month. I am not a php coder however so I do
not know how to modify. Here's the relevant chunk of code:
| Code: |
function read_items($d,$m,$y) {
$d=sprintf('%02.0f',$d);
$m=sprintf('%02.0f',$m);
$y=sprintf('%04.0f',$y);
if($d=='00'){
115> foreach($this->items_map[$y][$m] as $d=>$v){
if(is_array($this->items_map[$y][$m][$d]))
foreach($this->items_map[$y][$m][$d] as $k=>$v)
if(is_numeric($k)){
$this->items[$v]->day=$d;
$res[]=$this->items[$v];
}
else $res[$k] = $v;
}
}else{
if(is_array($this->items_map[$y][$m][$d]))
foreach($this->items_map[$y][$m][$d] as $k=>$v)
if(is_numeric($k)){
$this->items[$v]->day=$d;
$res[]=$this->items[$v];
}
else $res[$k] = $v;
}
if(is_array($res))
uasort($res,array('events','sort_by_day'));
return $res;
}
function sort_by_day($_a,$_b){
$a = $_a->day;
$b = $_b->day;
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
|
|
|
|
erik_1099
Junior Member
Posts: 8
Registered: 3/28/2008
Location: Southern California
Member Is Offline
|
| posted on 4/10/2008 at 09:18 PM |
|
|
I ended up suppressing the error message, but if anyone has a suggestion for actually fixing the issue, I'd appreciate it.
|
|
|
|