Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm getting this syntax error and I know it's PHP 101, but I wouldn't know php if it hit me over the head with a curly bracket. Any help would be appreciated. Thanks

<?php echo ($this->getProduct()->getCategory() ? $this->getProduct()->getCategory()->getName() : ‘no category’) ?>
share|improve this question

2 Answers 2

up vote 6 down vote accepted

What kind of apostrophe is that?

‘no category’

Should be

'no category'
share|improve this answer
    
Hah! Good catch, thanks. It was originally copypasted from a forum thread, so that's probably where the weird apostrophe came in. Thanks, that fixed the error :) –  Mark Simpson Dec 20 '09 at 10:44

; at the end of the statement?

share|improve this answer
2  
That semicolon is optional. –  Gumbo Dec 20 '09 at 10:11
    
Thanks, tried that and it didn't work. @Gumbo Thanks for the tip –  Mark Simpson Dec 20 '09 at 10:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.