Bug笔记:Fatal error: Uncaught Exception: UPDATE product SET tid = '88', virtual = '1',
06月15
记录一下平时工作中遇到的一些BUG,方便自己和大家今后再遇到类似问题时,能迅速避坑。
Bug提示
Fatal error: Uncaught Exception: UPDATE product SET tid = '88', sid = '0',
virtual = '1', logistics = '0', mrank = '0', mgold = '0',
isshow = '1', keywords = '', description = '板材' WHERE id = '42'
执行错误: 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 'virtual = '1',
logistics = '0', mrank = '0', mgold = '0',
isshow = '1', keywords'
at line 1 in /www/wwwroot/Functions.php:137 Stack trace:
#0 /www/wwwroot/include/mysql.php(40): syError() #1 /www/wwwroot/
syModel.php(191): db_mysql->exec() #2 /www/wwwroot/source/
admin/product.php(210): syModel->update() #3 /www/wwwroot/
Functions.php(16): a in /www/wwwroot/Functions.php on line 137
=============翻译过来其实大致意思是========================
致命错误:未捕获异常:更新产品类tid='88', sid = '0', title = '板材',
gourl = '', price = '405', virtual = '1', logistics = '0', mrank = '0', mgold = '0',
isshow = '1', keywords = '', description = '板材' WHERE id = '42'<br/>
执行错误: 您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,
以了解可在以下位置使用的正确语法:virtual='1',logistics='0',
mrank='0',mgold='0',isshow='1',keywords'
在/www/wwwroot/incl/Functions中的第1行。php:137堆栈跟踪:
#0/www/wwwroot/incl/mysql。
php(40):syError()#1/www/wwwroot/incl/syModel。
php(191):db_mysql->exec()#2/www/wwwroot/
product.php(210):syModel->update()
#3/www/wwwroot/incl/Functions。
php(16):一个位于/www/wwwroot/incl/Functions中的文件。php第137行
解决方案
乍一看,一脸懵,什么鬼,怎么会出现这种错误。
然后慢慢看,你会发现:
问题是由于virtual它其实是php预留字段,理解为是关键字,如果我们直接使用 哦吼 出现错误了。
处理方法:
1、修改字段名virtual
2、或者给字段名加上
符号``,也就是这样写`virtual`
有些错误是与生俱来的,只能尽量避开


版权:
徐伟轩博客-爱写歌的程序员思考和科普的日常自媒体
本文链接:
https://letus.top/archives/524.html(转载时需注明本文出处及文章链接)
如无特别注明,本站内容为原创。
如需转载或刊登,请联系我们获得授权。