AeonBackflash Posted September 9, 2009 Share Posted September 9, 2009 I have a really weird thing happening with a script I wrote that is supposed to rotate promotions pages at certain times of the year. I've set the script to create timestamps for the beginning and ending times for each promotion, then user IF/ELSE statements to compare the current timestamp with the date ranges, find the date range that the timestamp falls on, and include the promotion page associated with the correct promotion range. What is happening is that it seems to be stuck on the Easter Promotions condition. Here is the script: <?php function callheader() { echo('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Check Out Our Latest Promotions!</title> </head>'); } function isleapyear($febyear) { if ($febyear%400 ==0 || ($febyear%100 != 0 && $febyear%4 == 0)) return 29; else return 28; } $curdate=getdate(time()); $curyear=$curdate[year]; $curtimestamp=time(); $janpromostart=mktime(0,0,0,1,1,$curdate[year]); $febpromostart=mktime(0,0,0,2,1,$curdate[year]); $stpatpromostart=mktime(0,0,0,3,1,$curdate[year]); $easterpromostart=mktime(0,0,0,4,1,$curdate[year]); $summerpromostart=mktime(0,0,0,7,1,$curdate[year]); $schoolpromostart=mktime(0,0,0,9,1,$curdate[year]); $halloweenpromostart=mktime(0,0,0,10,1,$curdate[year]); $xmaspromostart=mktime(0,0,0,12,1,$curdate[year]); $janpromoend=mktime(23,59,59,1,31,$curdate[year]); $febpromoend=mktime(23,59,59,2,isleapyear($curdate[year]),$curdate[year]); $stpatpromoend=mktime(23,59,59,3,31,$curdate[year]); $easterpromoend=mktime(23,59,59,4,30,$curdate[year]); $summerpromoend=mktime(23,59,59,8,31,$curdate[year]); $schoolpromoend=mktime(23,59,59,9,30,$curdate[year]); $halloweenpromoend=mktime(23,59,59,10,31,$curdate[year]); $xmaspromoend=mktime(0,0,0,12,31,$curdate[year]); $curtimestamp=$summerpromostart; //echo $curtimestamp . "<br />" . $easterpromostart. "<br />" . $easterpromoend; callheader(); if (($curtimestamp >= $janpromostart) && ($curtimestamp<=$janpromoend)) { echo "New Years Promo"; include ("janpromoen.php"); } elseif (($curtimestamp >= $febpromostart) && ($curtimestamp<=$febpromoend)) { echo "Feb promotion"; include ("febpromoen.php"); } elseif (($curtimestamp >= $stpatpromostart) && ($curtimestamp<=$stpatpromoend)) { echo "St. Pat promotion"; include ("marpromoen.php"); } elseif (($curtimestamp >= $easterpromostart) && ($curstamp<=$easterpromoend)) { echo "Easter promotion"; include ("summerpromoen.php"); } elseif (($curtimestamp >= $summerpromostart) && ($curtimestamp<=$summerpromoend)) { echo "Summer promotion"; include ("summerpromoen.php"); } elseif (($curtimestamp >= $schoolpromostart) && ($curtimestamp<=$schoolpromoend)) { echo "Back To School"; include ("schoolpromoen.php"); } elseif (($curtimestamp >= $hwlloweenpromostart) && ($curtimestamp<=$halloweenpromoend)) { echo "Holloween"; include ("halloweenpromoen.php"); } elseif (($curtimestamp >= $xmaspromostart) && ($curtimestamp<=$xmaspromoend)) { echo "Merry Christmas"; include ("xmaspromoen.php"); } else echo('<p align="center">There are no promotions</p>'); ?> <p align="center">Training in Martial Arts is also mentally stimulating and FUN! Friendly, fully qualified Adult Black Belt Instructors will guide you through your Martial Arts training and experience. Equally suitable for men, women and children, it is an adventure of a lifetime - RIGHT HERE IN KINGSTON. Our Children , Teen and Adult programs (French and English) are run separately to better suit our students needs. Teens are welcome to attend Adult classes as well.<br /> <br /> We are looking forward to meeting and training with you. <b>Please note that your first three classes are FREE.</b> Come and take advantage of this <b>GREAT DEAL</b>. <br><br> You can call us at (613)547-4700 or <a href="mailto:[email protected]?subject=Promotion">email us!!</a><br> </p> <div align="center"><input type=button value="Close Window" onClick="javascript:self.close();"></div> </body> </html> If I comment this out, the script works: elseif (($curtimestamp >= $easterpromostart) && ($curstamp<=$easterpromoend)) { echo "Easter promotion"; include ("summerpromoen.php"); } I'm pretty sure I'm missing something. If anyone can maybe offer a second set of eyes and see something stupid that I'm missing, I would appreciate it. Thanks! Link to comment https://forums.phpfreaks.com/topic/173703-solved-unix-time-stamp-comparison-script/ Share on other sites More sharing options...
AeonBackflash Posted September 9, 2009 Author Share Posted September 9, 2009 Sorry, looks like it got cut off. I'll post the file... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/173703-solved-unix-time-stamp-comparison-script/#findComment-915672 Share on other sites More sharing options...
AeonBackflash Posted September 9, 2009 Author Share Posted September 9, 2009 *facepalm* Classic case of Syntax Error. I just figured it out.... Thanks Anyway! Link to comment https://forums.phpfreaks.com/topic/173703-solved-unix-time-stamp-comparison-script/#findComment-915678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.