Jump to content

[SOLVED] AGE


sstangle73

Recommended Posts

the function:

function emailTaken($email){
   global $conn;
   if(!get_magic_quotes_gpc()){
      $email = addslashes($email);
   }
   $qe = "select email from users where email = '$email'";
   $resulte = mysql_query($qe, $conn);
   return (mysql_numrows($resulte) > 0);
}
function birthday($birthday){   
list($month,$day,$year) = explode("-",$birthday);  

$today = getdate();   
$age = $today['year']-$year;   
if($month >= $today['mon'] && $day >= $today['mday']) {   

$age--; 

} 

return $age;  
} 

takes the birthday 10-11-1992 and returns 15 when it should be 14 can anyone see the error?

Link to comment
https://forums.phpfreaks.com/topic/67049-solved-age/
Share on other sites

Well this part:

 

$month >= $today['mon'] && $day >= $today['mday']

 

Wouldn't work all the time. This only works if the month and day are bigger than the birthday. Today being the 28th and the birthday you are testing the 11th that routine wouldn't work.

 

I think you need to add another check level.

Link to comment
https://forums.phpfreaks.com/topic/67049-solved-age/#findComment-336318
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.