Newbie problem with If...Else
Posted: Thu Apr 15, 2004 12:31 pm
Good evening everyone. I'm having a little problem with this script I've written to update my age on my website automatically:
The problem is that it keeps outputting "17", which is incorrect. From playing around with it I found that it skips the "if" and goes straight for the catch-all "else" condition, hence why I believe the problem lies in the conditions of the "if" statement. But I just can't seem to find what's wrong with it! Any ideas?
I'm just trying to teach myself PHP for the past week or so to give me something else to get my teeth into in the summer holidays, so I'd really appreciate the help.
Code: Select all
<?php
$year = date("Y");
$month = date("n");
$day = date("j");
if ($month < "8" and $day < "10") {
$age = $year - 1988;
} else {
$age = $year - 1987;
}
?>
<p><b>How old are you?</b><br>I am <?php echo $age; ?> years old</p>I'm just trying to teach myself PHP for the past week or so to give me something else to get my teeth into in the summer holidays, so I'd really appreciate the help.