Codeigniter:为什么我收到这个错误,“意外”(',期待标识符(T_STRING)或变量(T_VARIABLE)或'{'或'$'“?[重复]

This question already has an answer here:

Parse error: syntax error, unexpected '(', expecting identifier

(T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\wamp\www\ghostwriter\application\models\addproject_m.php on line 117

I am trying to create a pagination for my page, so i created a function to fetch the counts of the projects.

function get_projects_count(){
    $this->db->select->('p_id')->from('ghost_projects');
    $query=$this->db->get();
    return $query->num_rows();
}

The above code is in the model.

$this->data['projects'] = $this->addproject_m->ongoingprojects(5,$start);
    $this->load->library('pagination');
    $config['base_url'] = base_url().'project/search';
    $config['total_rows'] = $this->addproject_m->get_projects_count();
    $config['per_page'] = 5;
    $this->pagination->initialize($config);
    $data['pages']=$this->pagination->create_links();

And the above code is from the controller.

Can somebody please help me on this erro i am facing (new to codeigniter).

</div>

The problem is in 1 extra '->' that should not be there:

$this->db->select->('p_id')->from('ghost_projects'); //right here
$this->db->select('p_id')->from('ghost_projects'); //this is what it should be

The error tells you that you cannot have '(' after -> which makes sense since you have to ether specify the method name or variable name after ->.

In your query you have and extra -> near select->('p_id').You can also write you select query as

function get_projects_count(){
    $this->db->select('p_id');
    $this->db->from('ghost_projects'); // there was an extra > before from
    $query=$this->db->get();
    return $query->num_rows();
}