ok i am working on an event and calendar system for a site, very basic however ia am trying to create a function that will take all the events in the database and create an array with values for each day of the month. Basicaly have a 1 if there is an event that day and a 0 if not. however with the code that i have i seem to be getting an infinite loop with the section that fills the array with zero values for each day in the month

here is my code

Code:
function fSetEventOn($vResults,$vMonth,$vYear){
global $vEvents,$vDay;
$temp1  = getdate(mktime(0,0,0,$vMonth+1,0,$vYear));
$numdays=$temp2['mday'];
$vEvents = array();
$vDay = array();

$i=0;
while($row = mysql_fetch_array($vResults)){
if($row['event_year']==$vYear && $row['event_month']==$vMonth){
$vDay[$i]=$row['event_day'];
}
$i++;
}

//cause of the infinite loop, runs fine if this for loop is // out
for($i=1;$i<=$numdays['mday'];$i++){
$vEvents[$i]=0;
}

for($i=0;$i<=sizeof($vDay);$i++){
$vEvents[$Day[$i]] = 1;
}

return $vEvents;

}