dshgdhdfcas30210 2011-12-13 22:21
浏览 119
已采纳

Codeigniter在非对象上调用成员函数set_userdata()

I am getting a fatal error in a CI app that I just moved from a php4 shared host to a php5 shared host.

Fatal error: Call to a member function set_userdata() on a non-object in /home/chuck_ravenna/bob.ravennainteractive.com/system/application/helpers/authenticate_helper.php on line 13

Code in full located in the link below

https://gist.github.com/1474173

I am trying to figure out if the php version could be the issue. The site runs fine on the old server, and the new server doesn't have php4 as an option.

The specific code line thats breaking is:

    $this->session->set_userdata("admin", $user[0]["admin"]);
  • 写回答

4条回答 默认 最新

  • duanliaoyu8419 2011-12-14 03:40
    关注

    You can't use $this inside a helper as a helper file is just a collection of functions (no class there). To use the functionality provided by $this of controller, you'll have to do:

    $ci = & get_instance();
    $ci->session->set_userdata("admin", $user[0]["admin"]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效