Daney11 Posted March 23, 2007 Share Posted March 23, 2007 Hi guys. I have <?php $daymin = "01"; $monthmin = "01"; $yearmin = "1971"; $daymax = "30"; $monthmax = "12"; $yearmax = "1991"; for ($i = 1; $i < 22; $i++) { $dayofage = mt_rand($daymin, $daymax); $monthofage = mt_rand($monthmin, $monthmax); $yearofage = mt_rand($yearmin, $yearmax); $bdayunix = mktime('', '', '', $monthofage, $dayofage, $yearofage); $nowunix = time(); $ageunix = $nowunix - $bdayunix; $age = floor($ageunix / (365 * 24 * 60 * 60)); echo "$dayofage $monthofage $yearofage Age - $age<br />"; } ?> And im getting the error Warning: mktime() expects parameter 1 to be long, string given in D:\server\age.php on line 19 It work on my other server but not this. Any help would be great. Thanks guys. Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/ Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 Don't surround your number variables in quotes. Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213770 Share on other sites More sharing options...
Daney11 Posted March 23, 2007 Author Share Posted March 23, 2007 I still get the same error mate Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213773 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 $bdayunix = mktime('', '', '', $monthofage, $dayofage, $yearofage); Change that to this: $bdayunix = mktime(, , , $monthofage, $dayofage, $yearofage); Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213774 Share on other sites More sharing options...
Daney11 Posted March 23, 2007 Author Share Posted March 23, 2007 Now i get this error Parse error: parse error, unexpected ',', expecting ')' in D:\server\age.php on line 19 lol Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213776 Share on other sites More sharing options...
Daney11 Posted March 23, 2007 Author Share Posted March 23, 2007 SOLVED All i had to do was add 0's into the blank spaces $bdayunix = mktime('0', '0', '0', $monthofage, $dayofage, $yearofage); Thanks for helping anyway mate Thankyou Dane Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213777 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 My bad Should be $bdayunix = mktime(0, 0, 0, $monthofage, $dayofage, $yearofage); My bad. Link to comment https://forums.phpfreaks.com/topic/44027-solved-mktime/#findComment-213779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.