Reputation: 43
I want to take meta tags from an external webpage and save it into my mysql db, although I keep getting an error. Some help would be appreciated.
$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')");
The error I keep getting is this: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
Upvotes: 1
Views: 182
Reputation: 86406
desc
is a mysql reserved word either enclose that field name in backticks or rename the field name to something else.
eg.
mysql_query("INSERT INTO posts (userdesc,`desc`,title,url,userid)...
Upvotes: 3