Jump to content

[SOLVED] Undefined offset.


ineedhelpbigtime

Recommended Posts

I am getting an undefined offset error with this code. It is displaying the 3 rows that it should, but it trys to make a 4th one which is blank. Says undefined offset 3, so I'm guessing the first in the array is number 0.

 

<?php 

$bdays = array();

while($friendrow = mysql_fetch_array($friendresult))
{
    $birthdate = "$friendrow[birthday]";  
    list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $birthdate);
   	$YearDiff = date("Y") - $BirthYear;
    $MonthDiff = date("m") - $BirthMonth;
    $DayDiff = date("d") - $BirthDay;
    
// If the birthday has not occured this year

if ($MonthDiff == 0 && $DayDiff > -
{ 
 $bdays[] = $friendrow['userid'];
}

}

for($i=(0);$i<=count($bdays);$i++) {
echo count($bdays);
   print "$bdays[$i]<br>";
} 
?>

 

Any ideas? Im sure im making a stupid error here but im new to this. Its a steep learning curve  ???

Link to comment
https://forums.phpfreaks.com/topic/140456-solved-undefined-offset/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.