post时数据库出现错误

2013-11-13 20:33:51 +08:00
 yingluck
向网站提交数据时网站数据库出错,大概能看出是提交内容格式不正确,但是怎么改却没有头绪,求众V2EXer帮忙
INSERT INTO et_content (user_id,content_body,posttime,type) VALUES ('24579','<Storage {'title': u'fg'}>','1384345479','weixin') Error: 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 'title': u'fg'}>','1384345479','weixin')' at line 1
1874 次点击
所在节点    问与答
5 条回复
qiayue
2013-11-13 20:39:23 +08:00
('24579','<Storage {'title': u'fg'}>','1384345479','weixin')
改为
('24579','<Storage {"title": "ufg"}>','1384345479','weixin')
或者
('24579','<Storage {\'title\': \'ufg''}>','1384345479','weixin')

你原文的 u'fg' 我认为是你手误,你本来想写的是 'ufg' 吧?
qiayue
2013-11-13 20:39:57 +08:00
我也手误了
或者
('24579','<Storage {\'title\': \'ufg\'}>','1384345479','weixin')
shiny
2013-11-13 20:41:52 +08:00
怎么 content 存的这个,先把 python Storage 对象正确转成字符串+转义吧。
yingluck
2013-11-13 20:55:13 +08:00
@qiayue 多谢指正!
yingluck
2013-11-13 20:56:10 +08:00
@shiny 能详细讲一下吗?python 新手求问!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/89168

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX