Possible Duplicate:
Fatal error: Call to a member function query() on a non-object inPHP錯誤類裏面的函數裏面的類..等什麼?失去
我有一個類文件時,可以稱之爲「東西」
Stuff.class
裏面還有一類
class Stuff {
,並在那裏我有一個公共靜態功能
public static function morestuff() {
}
裏面我需要cal l另一個查詢功能
$q="Select from contacts where id =". $this->$db->escapeVal($ID)".";
但是我得到錯誤。
$q="Select from contacts where id =". escapeVal($ID)".";
返回
Call to undefined function escapeVal()
$q="Select from contacts where id =". $db->escapeVal($ID)".";
返回
Call to a member function escapeVal() on a non-object
$q="Select from contacts where id =". $this->$db->escapeVal($ID)".";
返回
Using $this when not in object context
所以,我該怎麼放?
編輯:
在同一文件中的類似功能具有下面的代碼
'id' = '" . $this->db->escapeVal($this->_Id) . "'
然而,當我嘗試在我的MySQL查詢使用此代碼我碰到下面的錯誤
Using $this when not in object context
可能與問題無關,但您需要'$ this-> db'而不是'$ this - > $ db'。 – 2012-07-09 19:32:07
謝謝,我也注意到了。 – 2012-07-09 19:35:53
而不是代碼和英語之間交替,呈現不間斷,完整,簡潔,具有代表性的[示例代碼](http://sscce.org/),以便它可以直接提供給PHP並按原樣運行。如果您需要評論,請使用評論。 – outis 2012-07-09 19:45:57