Copy link to clipboard
Copied
I have been working on this function – the idea is to read the meta tags – find the description – then insert the description in a db table.
I got the first two parts working – but cannot get the description to insert. I think I might need to do something to the array – i.e. addslashes or something – but, everything I try it does not seem to work. The odd thing is that I can echo the description ($value) but cannot insert it.
function getSiteMeta($description){
$tags = get_meta_tags($description);
if(sizeof($tags)==0){
echo 'No Description Found';
}
foreach($tags as $key=>$value) {
if($key!=description) {
unset ($value);
}
else
{
mysql_query("INSERT INTO page (page_description) VALUES ($value)");
echo $value;
}
}
}
Can someone provide a little guidance – please.
Copy link to clipboard
Copied
Stumbled upon a solution - or more of a work around. Not the prettiest of code but works great.
Copy link to clipboard
Copied
The obvious thing that's wrong with your original code is that $value needs to be in single quotes in the SQL query.
mysql_query("INSERT INTO page (page_description) VALUES ('$value')");
Copy link to clipboard
Copied
Thanks - yes, that was one (just one of many) of my problems. Thanks for your help.