Codeigniter 在非对象上调用成员函数 set_userdata()
我在刚刚从 php4 共享主机移至 php5 共享主机的 CI 应用程序中遇到致命错误。
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
完整代码位于下面的链接
https://gist.github.com/1474173< /a>
我试图弄清楚 php 版本是否是问题所在。该网站在旧服务器上运行良好,而新服务器没有 php4 作为选项。
破坏的具体代码行是:
$this->session->set_userdata("admin", $user[0]["admin"]);
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"]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您不能在助手中使用
$this
因为助手文件只是函数的集合(那里没有类)。要使用控制器的$this
提供的功能,您必须执行以下操作: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 =&获取实例();
$CI->加载->library('session');
$CI =& get_instance();
$CI->load->library('session');
您是否在构造函数中以及在parent::__construct() 指令之后加载会话库?
Are you loading the session librairy in the constructor and after the parent::__construct() instruction?
您正在使用 Codeigniter 的默认配置。
问题是:没有完成数据库配置!
您必须在此处输入:\YOUR_APPLICATION_NAME\application\config\database.php,
并且必须使用文本编辑器打开此文件。
设置以下变量即可完成:
You are using the default configuration of Codeigniter.
The problem is: NO DATABASE CONFIGURATION DONE!
You must enter here: \YOUR_APPLICATION_NAME\application\config\database.php
and you must open this file with a text editor.
Set the following variables and you are done: