0

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

Saty
  • 22,443
  • 7
  • 33
  • 51
DEV
  • 647
  • 4
  • 19
  • 31

2 Answers2

2

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

DannyPhantom
  • 1,042
  • 10
  • 21
1

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();
}
DEV
  • 647
  • 4
  • 19
  • 31
Saty
  • 22,443
  • 7
  • 33
  • 51