0

What's with this PHP Parsing Error Unexpected '{', expecting '('

No backtrace, no any other error message, just one line in the controller, that's it -_-

I kept looking for solutions and reading many links related to this.

What could be the reason for the error in my code below..

This was my controller code (which was working fine):

if (isset($filter) && !empty($search)) {
            $data['users'] = $this->model_search->searchTutor($field, $search);
        }
        elseif (($filter == 'subjName') && !empty($search)) {
            $data['users'] = $this->model_search->searchBySubj($field, $search);
        }
        else {
            $data['users'] = $this->model_search->getlist($field);
        }

        //later i wanted to add a code that will show No Result Found

The view file of my page started giving this error when I added an elseif statement in my controller (Search.php):

if (isset($filter) && !empty($search)) {
            $data['users'] = $this->model_search->searchTutor($field, $search);
        }
        elseif (($filter == 'subjName') && !empty($search)) {
            $data['users'] = $this->model_search->searchBySubj($field, $search);
        }
        //so I added another elseif
        elseif (isset($filter) && empty($search)) {
            $data['users'] = $this->model_search->getlist($field);
        }
        //and put the No Result last
        else {
            $this->session->set_flashdata('nores','<div class="alert text-center">No result matched your search.</div>');
        }

Is it because of the multiple elseif condition or am I really missing something here? Please help..

1 Answer 1

1
elseif {

Your new elseif has no condition. When do you expect it to run? You need to add a condition.

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

7 Comments

Thanks for pointing it out I edited it now.. But why won't it display the flashdata in the view? It's supposed to echo No Result...
@Distro That appears to be a completely different issue. If it is, you should mark this question as solved, and ask a new question.
@Distro where you what to see your flashdata?
@Distro Ya, np. When your ask the new question, make sure to include as many details about what you're trying to do as possible.
@Hikmat Sijapati I think I'll have to add some other conditions. I echo it in view: <?php echo $this->session->flashdata('nores'); ?>
|

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.