0

I am getting a parse error (unexpected T_Else) when trying to utilize the following code in my wordpress website. Any clue what it could be? Sorry new to PHP so bear with me.

<?php 
if (time() >= strtotime('11/28/2011') && time() <= strtotime('12/25/2011')) 
 { include (TEMPLATEPATH . '/stub_s10_Nov28-Dec25.php');
 }
else if (time() >= strtotime('12/26/2011') && time() <= strtotime('01/14/2012'))
 { include (TEMPLATEPATH . '/stub_s11_Dec26-Jan14.php');
 }
else if (time() >= strtotime('01/15/2011') && time() <= strtotime('02/14/2011'))
 { include (TEMPLATEPATH . '/stub_s2_Jan15-Feb14.php');
 } 
else if (time() >= strtotime('02/15/2011') && time() <= strtotime('03/17/2011'))
 { include (TEMPLATEPATH . '/stub_s3_Feb15-Mar17.php');
 }
else if (time() >= strtotime('03/18/2011') && time() <= strtotime('04/30/2011'))
 { include (TEMPLATEPATH . '/stub_s4_Mar18-Apr30.php');

else if (time() >= strtotime('05/01/2011') && time() <= strtotime('05/30/2011'))
 { include (TEMPLATEPATH . '/stub_s5_May01-May30.php');
 }
else if (time() >= strtotime('06/01/2011') && time() <= strtotime('07/04/2011'))
 { include (TEMPLATEPATH . '/stub_s6_Jun01-Jul04.php');
 }
else if (time() >= strtotime('07/05/2011') && time() <= strtotime('08/31/2011'))
 { include (TEMPLATEPATH . '/stub_s7_Jul05-Aug31.php');
 }
else if (time() >= strtotime('09/01/2011') && time() <= strtotime('10/31/2011'))
 { include (TEMPLATEPATH . '/stub_s8_Sep01-Oct31.php');
 }
else if (time() >= strtotime('11/27/2011') && time() <= strtotime('11/27/2011'))
 { include (TEMPLATEPATH . '/stub_s9_Nov01-Nov27.php');
 }
?> 
3
  • 1
    Does the error message give any indication of location of the error? It's generally a good idea to paste the exact error message into the question. Also, a generally good approach is to cut down your code to something smaller, and see if the problem still happens. If it still happens, you've got a more convenient example to show people. If the problem goes away, you've learned something useful about the problem (namely that it's somehow related to the material you cut out). Commented Jan 26, 2011 at 17:40
  • You know else if should be elseif as one word? Commented Jan 26, 2011 at 17:41
  • 1
    @Jonno_FTW: It can be one word, it doesn't have to be. Commented Jan 26, 2011 at 17:42

3 Answers 3

6

There's a missing close brace just after the "'/stub_s4_Mar18-Apr30.php')" line, which is most likely causing this issue.

Incidentally, you might want to store the current time in a variable rather than making repeated calls to the time() function. I'd also be tempted to use require_once, unless you specifically don't mind if the include fails.

Sign up to request clarification or add additional context in comments.

Comments

2

You forgot the closing } at line 17:

<?php 
if (time() >= strtotime('11/28/2011') && time() <= strtotime('12/25/2011')) 
 { include (TEMPLATEPATH . '/stub_s10_Nov28-Dec25.php');
 }
else if (time() >= strtotime('12/26/2011') && time() <= strtotime('01/14/2012'))
 { include (TEMPLATEPATH . '/stub_s11_Dec26-Jan14.php');
 }
else if (time() >= strtotime('01/15/2011') && time() <= strtotime('02/14/2011'))
 { include (TEMPLATEPATH . '/stub_s2_Jan15-Feb14.php');
 } 
else if (time() >= strtotime('02/15/2011') && time() <= strtotime('03/17/2011'))
 { include (TEMPLATEPATH . '/stub_s3_Feb15-Mar17.php');
 }
else if (time() >= strtotime('03/18/2011') && time() <= strtotime('04/30/2011'))
 { include (TEMPLATEPATH . '/stub_s4_Mar18-Apr30.php');
 }
else if (time() >= strtotime('05/01/2011') && time() <= strtotime('05/30/2011'))
 { include (TEMPLATEPATH . '/stub_s5_May01-May30.php');
 }
else if (time() >= strtotime('06/01/2011') && time() <= strtotime('07/04/2011'))
 { include (TEMPLATEPATH . '/stub_s6_Jun01-Jul04.php');
 }
else if (time() >= strtotime('07/05/2011') && time() <= strtotime('08/31/2011'))
 { include (TEMPLATEPATH . '/stub_s7_Jul05-Aug31.php');
 }
else if (time() >= strtotime('09/01/2011') && time() <= strtotime('10/31/2011'))
 { include (TEMPLATEPATH . '/stub_s8_Sep01-Oct31.php');
 }
else if (time() >= strtotime('11/27/2011') && time() <= strtotime('11/27/2011'))
 { include (TEMPLATEPATH . '/stub_s9_Nov01-Nov27.php');
 }
?> 

Comments

2

The fifth if block appears to be missing a close bracket.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.