[英]mysql syntax error with inserting website post
我正在编码网站的服务器端,我用它来存储帖子
if(!(mysql_query("INSERT INTO `post-data`(`site`, `source`, `meta-desc`, `title`, `figure`, `post`,`date`, `tags`, `category`) VALUES ('$this->site','$url','$this->meta_desc','$this->title','$this->figure',htmlentities($this->body),NOW(),'','')"))){
echo mysql_error();
die("DB_in_post Error");}
我没有问题,因为当我测试示例帖子时,我得到了mysql语法错误
您的SQL语法有误; 请查看与您的MySQL服务器版本相对应的手册,以获取在'附近使用的正确语法
作为一个人在20号线
当我使用htmlentities时,我看到此错误
您的SQL语法有误; 查看与您的MySQL服务器版本相对应的手册,以在'hello','world','foo'=>'bar'附近使用正确的语法);
如果你想'在线
Post_Link这是来自帖子部分的图像,该帖子使错误发生在关于编码的地方
所以我该怎么办?
似乎是您对htmlentities()
调用引起的引用问题(我将其更改为mysql_real_escape_string()
)
"INSERT INTO `post-data`
(`site`, `source`, `meta-desc`, `title`, `figure`, `post`,`date`, `tags`, `category`)
VALUES (
'$this->site',
'$url',
'$this->meta_desc',
'$this->title',
'$this->figure',
'" . mysql_real_escape_string($this->body) ."',
NOW(),
'',
''
)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.