我可能只是一直在看這個太久,但我沒有看到錯誤。任何幫助,將不勝感激。我的PHP/MySQL語法錯誤在哪裏?
錯誤:
Error occurred in [INSERT INTO 'PlayerSats' (username,character,FirstPlay) VALUES ('WaxyChicken','20','FALS')]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''PlayerSats' (username,character,FirstPlay) VALUES ('WaxyChicken','20','FALS')' at line 1
請注意, 「PlayerSats」 是不是一個錯字和正確大寫。
驗證碼:
if ($Funct == "SETFIRSTPLAY") {
$sql = "INSERT INTO $PlayerStats (username,character,FirstPlay) VALUES ('$username','$Char','FALS')";
mysql_query($sql) or die("Error occurred in [$sql]: " . mysql_error());
echo "SUCCESS";
}
表結構:
CREATE table PlayerStats (
ID int(10) unsigned not null auto_increment,
username char(20) not null default '' utf8_general_ci,
character char(2) not null default '00' utf8_general_ci,
invLand char(115) not null default '000:99' utf8_general_ci,
FirstPlay char(4) not null default 'true' utf8_general_ci,
Bank int(20) unsigned not null default 2000
);
已刪除的字符並使chrtr具有相同的屬性,嘗試了相同的命令:[INSERT INTO'PlayerSats'(username,chrtr,FirstPlay)VALUES('WaxyChicken' ,'21','FALS')]:你有錯誤在你的SQL語法中;檢查與您的MySQL服務器版本相對應的手冊,以在第一行 – WaxyChicken 2013-03-12 21:26:44
的'PlayerSats'(用戶名,chrtr,FirstPlay)VALUES('WaxyChicken','21','FALS')'使用表格名稱周圍的單引號...或者使用反引號或者根本不使用 – 2013-03-12 21:29:30
正確。我忘記了也從INSERT INTO'$ PlayerStats'中刪除單引號。錯誤已修復。謝謝大家。 $ sql =「INSERT INTO $ PlayerStats(username,chrtr,FirstPlay)VALUES('$ username','$ Char','FALS')」; – WaxyChicken 2013-03-12 21:31:10