duannima8347 2015-09-02 07:31
浏览 57
已采纳

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>
  • 写回答

2条回答 默认 最新

  • duandang9434 2015-09-02 07:36
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看