0
所以我一直在嘗試這一整天,我覺得有一個超級簡單的解決方案,我只是想念它。嘗試使用此查詢:插入一個ISO8601 DATETIME引發錯誤
INSERT INTO codes (`user_id`, `type`, `code`, `expires`) VALUES ($id, $type, $code, $expires);
這裏是 「過期」 值:
2016-11-13T00:14:43.000Z
散發出來查詢的錯誤:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':14:43.000Z)' at line 1
這裏的數據庫結構:
CREATE TABLE IF NOT EXISTS codes (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`code` varchar(255) NOT NULL,
`expires` DATETIME
)ENGINE=InnoDB;
我確實在$ expires變量上使用了real_escape_string。
任何人有任何建議嗎?
「字段列表」中的未知列'Subscriber'。 $ type變量是「Subscriber」。 我以前試過這個時出現這個錯誤。有任何想法嗎? – Nick
@尼克,同樣的問題。這是一個字符串,它需要引用'$ type'變量,否則數據庫會認爲您正在嘗試引用數據庫對象。 –
我覺得很愚蠢。非常感謝你的解釋<3 – Nick