2015-06-06 80 views
1

我可能只是太累了,並尋找一個小錯誤,但此代碼不會輸入任何信息到我的數據庫。問題與MySQLI

$sql = "INSERT INTO TABLE_NAME (UPC, Description, Make, Model, SNLocation, IMEI_MEID, Resetting, Notes, Image) 

VALUES ($UPC, $Desc, $Make, $Model, $SNLocation, $IMEI_MEID, $Resetting, $Notes, $Image)"; 

mysqli_query($con, $sql) or die(mysqli_error($sql)); 

有人可以幫我檢查這是否有語法問題或什麼?

回答

1

它,因爲你有一個錯誤

$sql = "INSERT INTO TABLE_NAME (UPC, Description, Make, Model, SNLocation, IMEI_MEID, Resetting, Notes, Image) 

VALUES ('$UPC', '$Desc', '$Make', '$Model', '$SNLocation', '$IMEI_MEID', '$Resetting', '$Notes', '$Image')"; 

去除]Notes, Image)]<-----和值需要被引用

+0

不幸的是,它仍然不工作.. –

+0

查看我的更新回答 –

+0

非常感謝。 –

1

您需要刪除]並隨附單引號字符串值('):

$sql = "INSERT INTO TABLE_NAME 
     (UPC, Description, Make, Model, 
     SNLocation, IMEI_MEID, Resetting, Notes, Image)] <-- Here --> 

VALUES ($UPC, $Desc, $Make, $Model, $SNLocation, $IMEI_MEID, $Resetting, $Notes, $Image)"; 

mysqli_query($con, $sql) or die(mysqli_error($sql)); 
+0

不幸的是,它仍然不能正常工作。 –

+0

@TimothyLee檢查編輯。 – Beginner