You have an error in your SQL syntax,该怎么解决
程序员文章站
2024-01-31 20:26:40
...
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']}', 这里多了个逗号
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']}', 这里多了个逗号
相关文章
相关视频
- 关于中英数字混的字串符分割问题_PHP教程
- PHP+TEXT留言本(三)_PHP教程
- 应用PHP标签模板实现什么任务_PHP教程
- php入门教程 精简版_PHP教程
- You have an error in your...
推荐阅读
-
You have an error in your SQL syntax,该怎么解决
-
SQL报错,You have an error in your SQL syntax; check the manual that corresponds to
-
php异常:You have an error in your SQL syntax; 急
-
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that co
-
mybatis java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;
-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
-
MySql-You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v
-
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version