2013-10-18 53 views
0

這有什麼問題?它返回「你在你的語法有錯誤......檢查,如果你有正確的MySQL版本使用附近的「來,內容鏈接)VALUES ...」這個查詢有什麼問題?語法錯誤

$notito = $idoftheguy; 
$contentofnoti = $username." just posted a comment on your update."; 
$linkofnoti = "http://mywebsite.net/post.php?id=".$thepostid; 
/* Now let's insert this */ 
$insertnoti = mysql_query("INSERT INTO newnotifications (to, content, link) VALUES ('$notito', '$contentofnoti', '$linkofnoti')"); 

以上所有的查詢中的東西存在於數據庫中。以下是給出錯誤的確切輸入(未嘗試任何其他輸入):

$ notito = 1;
$ contentofnoti =「Schart在您的更新中發佈了評論。」;
$ linkofnoti =「http://mywebsite.net/post.php?id=22」;

+11

'to'是一個MySQL的保留字,所以如果你使用它的表或列名,你需要把它們放在反引號 –

+0

哦,是我總是忘了!我犯了這麼多錯誤。謝謝 :) – imp

回答

1

如前所述。 to是一個存儲單詞。試試這個代碼:

$insertnoti = mysql_query("INSERT INTO newnotifications (`to`, `content`, `link`) VALUES ('$notito', '$contentofnoti', '$linkofnoti')");