Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHP Insert

Guest
Sep 09, 2009 Sep 09, 2009

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.

TOPICS
Server side applications

Views

573
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 10, 2009 Sep 10, 2009

Copy link to clipboard

Copied

Stumbled upon a solution - or more of a work around.  Not the prettiest of code but works great.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 10, 2009 Sep 10, 2009

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')");

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 12, 2009 Sep 12, 2009

Copy link to clipboard

Copied

LATEST

Thanks - yes, that was one (just one of many) of my problems.  Thanks for your help.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines