2016-02-26 51 views
-1

我有一個表評級,主要複合鍵的productId和帳戶及兩個可變名爲productId參數和用戶idDELETE SQL複合鍵

"delete from rating where productId = ".$this->ms($this->productId)." 
        AND userId= ".$this->ms($this->userId); 

什麼不對的SQL語法?我有一個錯誤消息 - >

您的SQL語法錯誤;檢查 對應於你的MySQL服務器版本正確的語法使用 附近「AND用戶id =」在行說明書2

+2

第一呼應你的SQL和控制檯運行它。 – Anish

+0

我的guss是'$ this-> ms($ this-> productId)'產生一個空字符串,所以真正地回顯命令並檢查那裏的語法。 – Shadow

+1

PHP和SQL是不同的語言。如果你有一個SQL語法錯誤,你需要看看**生成的SQL **。說,你參數錯了。使用預準備的語句 –

回答

0

試試這個

"delete from rating where productId = '$this->ms($this->productId)' 
        AND userId= '$this->ms($this->userId)'"; 
0

你應該調用函數在單引號''

試試下面的查詢: -

"DELETE FROM rating WHERE productId = '".$this->ms($this->productId)."' 
          AND userId= '".$this->ms($this->userId)."'"; 

希望它會幫助你:)