title: How do I check if the same tag was already in database with PHP and Mysql?
body: <p>I want this script to check to see if the same word has been entered if so it should add it to the count not add a duplicate tag.</p>
  
  <p>And if the tag entered is a new tag then let it add it to the database.</p>
  
  <p>Can some one help me fix this?</p>
  
  <pre><code>$tag = mysql_real_escape_string($_POST['tag']);
  $query = "INSERT INTO tags (tag, count) VALUES ('$tag', 1)
            ON DUPLICATE KEY UPDATE count = count+1";
  if (!mysql_query($query, $dbc))
    {
    die('Error: ' . mysql_error());
    }
  echo "1 record added";
  
  mysql_close($dbc)
  </code></pre>
  
  <p>THANKS EVERYONE I GOT IT TO WORK BUT ANOTHER PROBLEM CAME UP BUT IT'S A DIFFERENT QUESTION</p>