Hi,

I have tried using the code below in a node template file but keep getting this message:

Parse error: syntax error, unexpected ':'

 if ($_SESSION['smart_ip']['location']['country_code'] == 'AT' ||  ($_SESSION['smart_ip']['location']['country_code'] == 'Be' || ($_SESSION['smart_ip']['location']['country_code'] == 'BG' || ($_SESSION['smart_ip']['location']['country_code'] == 'CY' || ($_SESSION['smart_ip']['location']['country_code'] == 'CZ' ||  ($_SESSION['smart_ip']['location']['country_code'] == 'SE' || 
($_SESSION['smart_ip']['location']['country_code'] == 'FR'): 

€1.99

elseif ($_SESSION['smart_ip']['location']['country_code'] == 'UK'):

£1.99

else:

$1.99

endif;

any ideas?

Thanks again for your help Roland

Comments

dman’s picture

Yes.
Your code syntax is crap.
Each ( must be matched with one closing ).
The condition you posted up there is totally unbalanced.
Either have just one pair of brackets there, with all the conditions inside it (it'll work, but may look ambiguous), or nest your brackets so each == condition is grouped tidily.

if ($_SESSION['smart_ip']['location']['country_code'] == 'AT' || $_SESSION['smart_ip']['location']['country_code'] == 'Be' ) :

or

if ( ($_SESSION['smart_ip']['location']['country_code'] == 'AT') || ($_SESSION['smart_ip']['location']['country_code'] == 'Be') ) :
arpeggio’s picture

Status: Active » Fixed

You have missing closing parenthesis. Please follow dman's advice. Thanks.

nyleve101’s picture

Thanks for explanation.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rdentry’s picture

I'm doing basically the same thing, hiding fields based on "country code". I'm guessing if I want to do this with views, I would have to format the teaser in the theme using this code and just print out the teaser in a view? Not sure if this kind of support is available in the fields part of views (I know you can't add this in the 'rewrite output' area). Just wondering if there are any alternatives using this sort of filtering with views?

arpeggio’s picture

Hi rdentry, sorry for the delay. The Smart IP for D6 now do have Views filter. Thanks.