$SourceID = $this->source_information->SourceID;
// the following fails
if($results = $this->mysqli->query("SELECT .... R.Name = '$release_name' AND S.SourceID = $this->source_information->SourceID AND S.ReleaseID = R.ReleaseID"))
// this will works
if($results = $this->mysqli->query("SELECT .... R.Name = '$release_name' AND S.SourceID = $SourceID AND S.ReleaseID = R.ReleaseID"))
我有一噸重的有$代碼這個 - > source_information->的SourceID排序如果它和我的東西真的沒有什麼重寫它告訴我,我可以使這個工作如何。PHP開捕致命錯誤:類stdClass的客體不能轉換成字符串
編輯如下:
出口(的var_dump($這個 - > source_information->的SourceID));
回報(字符串(2) 「18」)
謝謝你帶了預處理語句。我將從現在開始使用準備好的陳述。
請郵寄出境的'結果(後續代碼var_dump($這個 - > source_information->的SourceID));' –
當使用'mysqli'你應該使用參數化查詢和['bind_param'](http://php.net/manual/en/mysqli-stmt.bind-param.php)將用戶數據添加到您的查詢中。 **不要**使用字符串插值來實現此目的,因爲您可能會創建嚴重的[SQL注入漏洞](http://bobby-tables.com/)。 – tadman
exit(var_dump($ this-> source_information-> SourceID));返回字符串(2)「18」 – user1564382