View Full Version : Won't Correctly Show Month Name When User Hits Next
audiophreak
01-30-2009, 03:45 PM
I am having a weird bug occuring with my calendar. When the user hits next month button on the calendar it won't show the month of February in the header. The variable shows it being 2, but March is displayed. You hit next again and it shows March correctly and April if you hit it again.
The Calendar for February is there, but the actual header is wrong.
It's hosted here:
http://www.cosmolava.com/v2/calendar.php
Any ideas? We've had no luck figuring this out. Here is the part that pulls in the custom graphical header based on the month.
<?php
(($_REQUEST['mo']=="") ? ($mo = date("m")) : ($mo = $_REQUEST['mo']));
$epcMonthPic = date("F", mktime(0,0,0,$mo)); //change the "F" for "m" if you want to use numbers
$epcImagePath = "http://www.cosmolava.com/v2/images/"; // the path to your monthly images (keep the trailing slash)
$epcImageExt = "jpg"; // the extension you'll be using for your images
echo "<img src=\"$epcImagePath$epcMonthPic.$epcImageExt\">";
?>
Brian
01-30-2009, 09:13 PM
Technically, the bug isn't with the calendar (just in case someone else reads this), but with the custom modifications being made.
It's probable that it's because of February possibly being a leap year sometimes, and/or the time change in March.
Because of this, I always use the full mktime function and account for the time change by calling it like:
mktime(3, 0, 0, $mo, 01, $yr);
audiophreak
01-30-2009, 10:14 PM
Thanks I'll give it a try and see if that helps. It was doing the same with January last month so I am not sure it's an actual leap year thing.
audiophreak
01-30-2009, 10:22 PM
How would I need to modify the above code to incorporate this? I swapped out the portion you mentioned and it broke the script.
That piece of code i posted above is something you guys wrote for me. This modification is actually something you guys helped me incorporate when I first put the calendar into the site a few years ago.
Brian
01-30-2009, 11:56 PM
How does it break the script? Errors? What does it do.?
I am "you guys" and I don't remember writing this code... Maybe another forum user helped? :)
audiophreak
01-31-2009, 09:07 AM
I just replaced the mktime portion in the 2nd line in the code block I have above. That's what broke it.
The thread where this originated is here:
http://www.easyphpcalendar.com/forums/showthread.php?t=6782
But in that thread he (ve9gra) referenced another thread that helped with the monthly image portion that is here - It's post #10 in this thread:
http://www.easyphpcalendar.com/forums/showthread.php?t=6178
Also I should probably mention that I am not using version 6 of the calendar, still version 5. I wanted to hold off upgrading until we redo the whole site in a few months. If we need to upgrade it though to make this easier I will.
Brian
01-31-2009, 09:25 AM
Yeah, that's why I don't remember writing the code; ve9gra did.
Again, what are the error messages? Can't try fix it without knowing what's causing it...
audiophreak
01-31-2009, 09:29 AM
no error messages... the page just shows up blank. :(
This portion is above it... Do I need to tweak this part to make the part you wanted me to tweak work?
<?php
(!isset($_REQUEST['mo'])?$mo=date('m'):$mo=$_REQUEST['mo']);
(!isset($_REQUEST['yr'])?$yr=date('Y'):$yr=$_REQUEST['yr']);
$yb=$yr;
$yf=$yr;
$mb=$mo-1;
if ($mb<1) {$mb=12; $yb=$yr-1;}
$mf=$mo+1;
if ($mf>12) {$mf=1; $yf=$yr+1;}
$cmo = date("m");
$cyr = date("Y");
?>
ve9gra
01-31-2009, 10:58 AM
I actually found my old test file on my server and the issue was present here too. With the recomendation from Brian's first post, I tested it and it works.
The line that's changed is the $epcMonthPic
<?php
(($_REQUEST['mo']=="") ? ($mo = date("m")) : ($mo = $_REQUEST['mo']));
$epcMonthPic = date("F", mktime(3,0,0,$mo,1)); //change the "F" for "m" if you want to use numbers
$epcImagePath = "http://www.cosmolava.com/v2/images/"; // the path to your monthly images (keep the trailing slash)
$epcImageExt = "jpg"; // the extension you'll be using for your images
echo "<img src=\"$epcImagePath$epcMonthPic.$epcImageExt\">";
?>
audiophreak
01-31-2009, 11:10 AM
Awesome thanks... Working great now!
vBulletin® v3.8.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.