sstangle73 Posted September 2, 2007 Share Posted September 2, 2007 when i use this function function birthday($birthday){ list($month,$day,$year) = explode("-", $birthday); birthday is 3-23-1992 it comes back 1 23 1992 every month turns into one for some reason. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 2, 2007 Share Posted September 2, 2007 so you're saying when you print $month it says 1? or is there more to the code? What "comes back" Quote Link to comment Share on other sites More sharing options...
Fadion Posted September 2, 2007 Share Posted September 2, 2007 I just tried it myself and im getting no problems. As jesirose said, post some more code. Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted September 2, 2007 Author Share Posted September 2, 2007 theres more to the code but yes when i print month it comes back one full code ": function birthday($birthday){ list($month,$day,$year) = explode("-", $birthday); $today = getdate(); $age = $today['year']-$year; if(($month=$today[mon] && $day > $today[mday])){ $age--; } return $birthday . " " . $month . " " . $day . " " . $year . " " . $age; } the $birthday . " " . $month . " " . $day . " " . $year . " " . was just added so i can try to trouble shoot the code and what i have prints 3-23-1992 1 23 1992 14 whem i am 15 Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 2, 2007 Share Posted September 2, 2007 first of all you need to make your array keys which are strings surrounded by quotes. $today['mon'] not $today[mon] Secondly, = is the assignment. == is equal to. Change $month=$today[mon] to : $month==$today['mon'] And I think something is wrong with your time if it thinks today is January. PS: Your age function has some other flaws. Why did you change it? http://www.phpfreaks.com/forums/index.php/topic,157084.msg683302.html#msg683302 Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted September 2, 2007 Author Share Posted September 2, 2007 dont you love when a f*cking = throws off an entire code. function birthday($birthday){ list($month,$day,$year) = explode("-", $birthday); $today = getdate(); $age = $today['year']-$year; if(($month==$today['mon'] && $day > $today['mday'])){ $age--; } return $birthday . " " . $month . " " . $day . " " . $year . " " . $age; } Thanks! Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 2, 2007 Share Posted September 2, 2007 PS: Your age function has some other flaws. Why did you change it? http://www.phpfreaks.com/forums/index.php/topic,157084.msg683302.html#msg683302 Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted September 2, 2007 Author Share Posted September 2, 2007 somewhere in trouble shooting on my own [when phpfreaks was down this morning] i got rid of it thanks for reminding me Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.