title: error in update table using ON DUPLICATE KEY UPDATE
body: <p>I'm reading and store rss feed in my database ,my requirement is if link field is same then update title and description only in database.<br>
   I'm using ON DUPLICATE KEY UPDATE but after entered query.its insert only a single data in database  and failed and show a error</p>
  
  <p>my code is </p>
  
  <pre><code> &lt;?php
        include_once 'db.php';
  
           $homepage = file_get_contents('http://rss.cnn.com/rss/edition_us.rss');
  
            $movies = new SimpleXMLElement($homepage);
               foreach($movies-&gt;channel-&gt;item as $opt){
              $title= $opt-&gt;title;
              $tittle=mysql_real_escape_string($title);
              $link=$opt-&gt;link;
              $links=mysql_real_escape_string($link);
              $des=$opt-&gt;description;
  
          $dess=mysql_real_escape_string($des);
  
         "INSERT INTO store_feed (title, link, description) VALUES   ('$tittle','$links','$dess')";
  
  
  
         $sql="ON DUPLICATE KEY UPDATE title= '$tittle',description='$dess'";
        $result=mysql_query($sql) or die( mysql_error() );
          }
  
        ?&gt;
  </code></pre>
  
  <p>and table structure is:-</p>
  
  <pre><code> CREATE TABLE `test_om`.`store_feed` (
     `id` INT NOT NULL AUTO_INCREMENT ,
       `title` VARCHAR( 200 ) NOT NULL ,
       `link` VARCHAR( 200 ) NOT NULL ,
        `description` VARCHAR( 500 ) NOT NULL ,
      `feedburner` VARCHAR( 200 ) NOT NULL ,
      PRIMARY KEY ( `id` ) ,
       UNIQUE (
       UNIQUE KEY `link` (`link`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  </code></pre>
  
  <p>and error is
  Duplicate entry 'http://rss.cnn.com/~r/rss/edition_us/~3/Wl1V4JsNqDU/index.html' for key 'link'</p>
  
  <p>I have done some changes in my query ,short it.</p>
  
  <pre><code>     &lt;?php
       include_once 'db.php';//config file
  
       $homepage = file_get_contents('http://rss.cnn.com/rss/edition_us.rss');//link of rss feed page
        $movies = new SimpleXMLElement($homepage);
  
        foreach($movies-&gt;channel-&gt;item as $opt){ 
  
        $sql="INSERT INTO store_feed SET `title` = '".mysql_real_escape_string($opt- &gt;title)."',
       `link`='".mysql_real_escape_string($opt-&gt;link)."',
        `description`='".mysql_real_escape_string($opt-&gt;description)."'"
  
       ."ON DUPLICATE KEY UPDATE `title`='".mysql_real_escape_string($opt-&gt;title).
        "',`description`='".mysql_real_escape_string($opt-&gt;description)."'";
  
      $result=mysql_query($sql) or die( mysql_error() );
      }
    ?&gt;
  </code></pre>
  
  <p>and its solve my problem....</p>