我有問題與$mysqli->prepare
用下面的代碼:問題與mysqli的準備
if (!($stmt = $mysqli->prepare("INSERT INTO `Orders` (OrderID,IP.Email.File,Cat,Price,Discount,Size,Scaleby,Emailed,Downloaded,Payment,DateTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
當前代碼:
if (!($stmt = $mysqli->prepare("INSERT INTO `Orders` (OrderID,IP,Email,File,Cat,Price,Discount,Size,Scaleby,Emailed,Downloaded,Payment,DateTime) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"))) {
echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
錯誤消息:
準備失敗:(1136)列計數與第1行的值計數不匹配
代碼用來做表:
if ($mysqli->query('CREATE TABLE IF NOT EXISTS `Orders` (
ID BIGINT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(ID),
OrderID CHAR(40),
IP CHAR(40),
Email VARCHAR(254),
File VARCHAR(30),
Cat VARCHAR(30),
Price DEC(5,2),
Discount DEC(3,2),
Size VARCHAR(30),
Scaleby DEC(3,2),
Emailed BOOL,
Downloaded BOOL,
Payment VARCHAR(30),
DateTime DATETIME)') === False){
printf("Error: %s\n", $mysqli->error);
}
我嘗試,試圖修復錯誤去除INSERT INTO...
(...)
,但沒有奏效。 我也試圖簡化它到3 ?
馬克,但它仍然沒有工作。
的?
馬克在一份聲明中
您用字點而不是逗號分隔字段名稱'IP','Email'和'File'。 – eggyal
如果您**閱讀**錯誤消息「列計數與第1行的值計數不匹配」 - 那麼您會明白它的含義。 – zerkms
@zerkms大聲笑,我做了,但它很神祕。 – linuxrules94