我想从外部网页获取meta标签并将其保存到我的mysql数据库中,尽管我不断收到错误。一些帮助将不胜感激。
$tags = get_meta_tags($_POST['url']);
if (array_key_exists("description", $tags)){
$desc = mysql_real_escape_string($tags['description']);
}
$postQ = mysql_query("INSERT INTO posts (userdesc,desc,title,url,userid) VALUES ('$userdesc','$desc','$title','$url','$userid')");
我不断得到的错误是: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 'desc,title,url,userid) VALUES ('Wow this house is small','We've featu' at line 1
答案 0 :(得分:3)
desc
是一个mysql reserved word,或者在反引号中包含该字段名称,或者将字段名称重命名为其他名称。
例如。
mysql_query("INSERT INTO posts (userdesc,`desc`,title,url,userid)...