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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.