codeigniter-3php-parse-error

CodeIgniter PHP Parsing Error unexpected '{', expecting '('


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..


Solution

  • elseif {
    

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