【问题标题】:Call to member function调用成员函数
【发布时间】:2011-08-17 15:14:09
【问题描述】:

我有以下代码,我正在尝试理解并找到解决此错误的方法。

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Tank_auth::$users

Filename: libraries/Tank_auth.php

Line Number: 188

Fatal error: Call to a member function UpdateProfileInfo() on a non-object in /home/xtremer/public_html/kowmanager/application/libraries/Tank_auth.php on line 188

坦克验证控制器:http://pastebin.com/iRj11hgR 坦克认证型号:http://pastebin.com/qhNK5Whz 坦克认证库:http://pastebin.com/RVxdzhUa

编辑:感谢 Marc,他能够找到问题,但奇怪的是我确实遇到了一个新问题。

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userID

Filename: libraries/Tank_auth.php

Line Number: 188
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/xtremer/public_html/system/core/Exceptions.php:170)

Filename: libraries/Session.php

Line Number: 671
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/xtremer/public_html/system/core/Exceptions.php:170)

Filename: helpers/url_helper.php

Line Number: 543

【问题讨论】:

  • application/libraries/Tank_auth.php 好像没有 188 行??
  • 在您粘贴的任何代码示例中都没有 $users,并且所有代码示例都没有第 188 行。您在阻止我们...
  • 我只是想提供相关的代码,所以无论如何它并没有让任何人失去帮助。
  • 我更新了所有链接以包含完整代码。

标签: php codeigniter


【解决方案1】:

可能相关:

第 187 行:$this->ci->users
第 188 行:$this->users->UpdateProfileInfo(...);

在 Tank Auth 库中忘记了 ->ci

【讨论】:

  • 这解决了一件事。有趣的是,我解决了一个问题而发现了另一个问题。我的新错误在我的帖子中。
  • PHP 数组键区分大小写。也许是user_iduserid 而不是userID? 很难说。修复未定义索引警告后,标题错误/警告应该消失。
  • 我改变了 $this->ci->users->UpdateProfileInfo($userInfo['userID'],$userInfo['first_name'],$userInfo['last_name']);到这个 $this->ci->users->UpdateProfileInfo($userInfo['user_id'],$userInfo['first_name'],$userInfo['last_name']);仍然出现同样的错误。
  • 这太令人沮丧了,但我却如此接近。
  • 试试var_dump($userInfo) 看看里面有什么,而不是仅仅猜测键名。
【解决方案2】:

您的 tank_auth/users.php 模型似乎没有加载,或者某处存在命名冲突。你的 $autoload 数组是什么样的?

【讨论】:

  • $autoload['libraries'] = array('database','template','asset','session');
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-15
  • 2016-12-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-04
相关资源
最近更新 更多