首頁 >後端開發 >php教程 >You have an error in your SQL syntax,该怎么解决

You have an error in your SQL syntax,该怎么解决

WBOY
WBOY原創
2016-06-13 10:33:332266瀏覽

You have an error in your SQL syntax
function _query($_sql) {
if (!$_result = mysql_query($_sql)) {
exit('SQL执行失败'.mysql_error());
}
return $_result;
}
function _fetch_array($_sql) {
return mysql_fetch_array($this->_query($_sql),MYSQL_ASSOC);
}
function _is_repeat($_sql,$_info) {
if ($this->_fetch_array($_sql)) {
_alert_back($_info);
}
}

_is_repeat(
"SELECT commodity_name FROM commodity WHERE commodity_name='{$_goods['commodity_name']}' LIMIT 1",
'对不起,此商品已经存在'
);
$DB->_query(
"INSERT INTO commodity(
commodity_name,
Sale_Address,
Seller,
Production_Address,
Company,
permit_number,
content
)
VALUES(
'{$_goods['commodity_name']}' ,
'{$_goods['Sale_Address']}',
'{$_goods['Seller']}',
'{$_goods['Production_Address']}',
'{$_goods['Company']}',
'{$_goods['permit_number']}',
'{$_goods['content']}',

)"

);



?>

我的程序运行出现错误: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 ')' 。代码太多,我只把与问题相关的代码贴了出来,如果看不出来我可以发全部代码。希望各位大神帮帮忙,我还是个新手,希望能说的通俗一点,谢谢

------解决方案--------------------
'{$_goods['content']}', 这里多了个逗号

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn