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 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行