tags:

views:

47

answers:

2

I get this error:

Fatal error: Call to undefined function () in /home/gmfeedsc/domains/cekdahl.com/public_html/virek/system/application/views/rekommendationer/visa.php on line 263

And that row is:

<?php if ( ($post['users_id'] == $this->userId) || ($this->userLevel > 0) ): ?>

And I can't figure it out. I guess it is because it thinking ( ) around the comparison is a function, but how else could I write this? thanks.

EDIT: My script is a Codeigniter view, and the surrounding code is only XHTML. Since practice mandates that I shouldn't retrieve variables by $this-> in the view, I made them variables instead and the code looks like this now:

<?php if ( ($post['users_id'] == $userId) || ($userLevel > 0) ): ?>

These statements work independently, the problem arises when I put them together.

A: 

It might be because you have no <?php endif; ?> after your conditional (XHTML) action.

(see the PHP manual page.)

scott77777
A: 

There is nothing wrong with this code. However, try writing it like this:

if ($post['users_id'] == $userId or $userLevel > 0)

If you are still having issues, try nested ifs to see if you get the same result:

if ($post['user_id'] == $userId) {
    if ($userLevel > 0) {
cdburgess
that would be a -1 if I had any votes left for suggesting the unnecessary nested ifs (ugghh) instead of solving the problem
aaronasterling
somehow the first suggestion actually worked!! Of course nested ifs won't work though. I agree with aaronasterling about that: it doesn't do the same thing.
Calle
I agree... I hate if. If you reread my comment, I am suggesting it be tried to see if Calle get's the same results. Sorry if you took it to imply it would be a "good" solution. But the base solution is to remove the additional unneeded parenthesis.
cdburgess