HughbertD Posted December 6, 2007 Share Posted December 6, 2007 Hi, I am getting the following error when clicking "next month" on my calendar, Warning: mktime() expects parameter 4 to be long, string given in calendar.php The line it references shows the mktime as - $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); I'm not sure why this is wrong, I checked on W3schools and i think the syntax are correct, I was reluctant to post all the code as its quite large, but can if the problem is not within the snippet I posted, Thanks for any help Regards Hugh Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 6, 2007 Share Posted December 6, 2007 Are you sure your variables within mktime are valid? <?php echo "mon = $mon<br>tday = $tday<br>year = $year<br>" die(); $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407800 Share on other sites More sharing options...
kishan Posted December 6, 2007 Share Posted December 6, 2007 try to convert $mon and the remaining params in to like intval($mon) then try to execute Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407803 Share on other sites More sharing options...
HughbertD Posted December 6, 2007 Author Share Posted December 6, 2007 Are you sure your variables within mktime are valid? Hi, I am not sure whether the variables ARE valid or not, here is the code above the mktime that defines the variables <?php echo "mon = $mon<br>tday = $tday<br>year = $year<br>" die(); $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); PhREEEk Hi, <?php $ev_dat = array(); for ($i=0;$i<32;$i++) { $ev_dat[$i]=0; } $now = date("Y-m-d", time()); list($ty, $tm, $td) = explode('-',$now); // ty=thisyear, etc. used for highlighting 'today' include("cal_parms.php"); // assorted configuration variables include($dat_names); // retrieved from cal_parms.php as a 'language' file if (!isset($_GET['m'])) { $m = date("m",mktime()); } else { $m = $_GET['m']; } if (!isset($_GET['y'])) { $y = date("Y",mktime()); } else { $y = $_GET['y']; } /*== get what weekday the first is on ==*/ $tmpd = getdate(mktime(0,0,0,$m,1,$y)); $month = $tmpd["month"]; $firstwday= $tmpd["wday"]; if ($firstDayIsMonday == 1) { if ($firstwday == 0) { $firstwday = 6; } else { $firstwday--; } } $lastday = mk_getLastDayofMonth($m,$y); /*== get the last day of the month ==*/ function mk_getLastDayofMonth($mon,$year) { for ($tday=28; $tday <= 31; $tday++) { $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); if ($tdate["mon"] != $mon) { break; } } $tday--; return $tday; } Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407811 Share on other sites More sharing options...
HughbertD Posted December 6, 2007 Author Share Posted December 6, 2007 Hi again, Sorry, I've realised what you were saying, I used the echo to show the variables, clicked next and got: EDIT: I wasn't clicking next, these are the variables when I click next, these are invalid right? mon = 12) ? 1 : $m 1 ?> tday = 28 year = 12) ? $y 1 : $y ?> Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407815 Share on other sites More sharing options...
PHP_PhREEEk Posted December 6, 2007 Share Posted December 6, 2007 kishan is correct: http://us.php.net/manual/en/function.mktime.php Values must be integers PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407817 Share on other sites More sharing options...
HughbertD Posted December 6, 2007 Author Share Posted December 6, 2007 Thanks Kishan, Thats removed the errors! One other thing I am having trouble with is when clicking "next" month, it can't seem to calculate the what the next month is! Usually for "show events" I have, http://localhost/joStark/calendar/show-month.php?mon=12&yr=2007 As my URL, I understand that much, but when I click next month it turns to gibberish, I would have thought that next month would be calculated by adding one to the month value, but the code says: <th width="20" style="<? echo $hcell; ?>"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>"><img src='calendar/images/next.gif' height='18' width='18' border='0' alt='' /></a></th> This seems really over the top, or am I missing something important? Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407833 Share on other sites More sharing options...
kishan Posted December 6, 2007 Share Posted December 6, 2007 im not getting exactly but the code u have written in correct only. can u clear ur queston clearly. Quote Link to comment https://forums.phpfreaks.com/topic/80428-help-with-mktime/#findComment-407840 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.