I tried this and I'm getting a parse error:I'm just trying to pick what quarter you're in based on what month it is.PHP Code:<?php
if(date(n)<4?1:if(date(n)<7?2:if(date(n)<10?3:4)));?>
Printable View
I tried this and I'm getting a parse error:I'm just trying to pick what quarter you're in based on what month it is.PHP Code:<?php
if(date(n)<4?1:if(date(n)<7?2:if(date(n)<10?3:4)));?>
What's the error you do get?
And what is 'n' ? You do know that variables in PHP start with $, right?
TG
the error was a "T_IF" or something error. n is a date notation for the month with no leading zeros... it needs quotations in that piece of code, but I have since put them in and I still get the error.
Quote:
Originally posted by ober5861
I tried this and I'm getting a parse error:I'm just trying to pick what quarter you're in based on what month it is.PHP Code:<?php
if(date(n)<4?1:if(date(n)<7?2:if(date(n)<10?3:4)));?>
You need to put the brackets in the right place.PHP Code:<?php if(date(n)<4)?1:(if(date(n)<7)?2:(if(date(n)<10)?3:4));?>
May I also suggest that if you are having trouble finding the error you make the code clearer. IE.
PHP Code:<?php (date (n) < 4) ? 1 : ((date (n) < 7) ? 2 : ((date (n) < 10) ? 3 : 4)) ?>
Thanks. It's all about the parens. :rolleyes: