You have an error in your SQL syntax,该怎么解决
程序员文章站
2022-06-06 09:05:57
...
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数据库迁移工具“Phinx”
- 详解win10下PHP的安装配置(以php5.6为...
- php Swoole实现毫秒定时计划任务(详解)
- PHP安全配置_php技巧
- You have an error in your...
推荐阅读
-
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
-
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错误:[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use