我有這樣的代碼,並由於某種原因,我得到這個錯誤INSERT Error - 如果文件EMPTY功能無法正常工作
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 's','Used','A Book','1','http://media1.' at line 2
CODE:
if(empty($_POST['image'])) {
$file = 'http://media1.site.org/products/images/no-photo.jpg';
} else {
define('UPLOAD_DIR', '/products/images/');
define('UPLOAD_HOST', 'http://media1.sabinalcanyon.org/products/images/');
move_uploaded_file($_FILES['image']['tmp_name'],UPLOAD_DIR.$_FILES['image']['name']);
$file = UPLOAD_HOST.$_FILES['image']['name'];
}
$descedit = "<p>".$_POST['description']."</p>";
mysql_query("INSERT INTO products (`title`,`barcode`,`ISBN`,`catagory`,`set_price_start`,`brand`,`condition`,`description`,`amount_stock`,`picurl`)
VALUES('$_POST[title]','$_POST[barcode]','$_POST[ISBN]','$_POST[catagory]','$_POST[set_price_start]','$_POST[brand]','$_POST[condition]','$descedit','$_POST[amount_stock]','$file')") or die(mysql_error());
2號線是這個塊的僅僅是開始的代碼。
很好。你有一個錯誤(和一個大的SQL注入安全漏洞)。我們都去過那裏。現在,*你到底做了什麼來調試這個*? (對於初學者來說,生成的查詢字符串是什麼?) –
檢查你的'$ _POST [品牌]'值。 –
你很容易受到[SQL注入攻擊](http://bobby-tables.com)的影響。你很容易受到文件注入攻擊。 **請勿將此代碼用於生產系統**。 –