title: Mysql insert data if not exist else show warning
body: <p>I need to check if value already exist in table and insert it if not exist, else i need to show alert about exception</p>
  
  <p>Now i insert only data without checking</p>
  
  <pre><code>if(isset($_POST['new_ok'])){$result = mysql_query("INSERT INTO db1 (name) VALUES('".$name."')",$db);}
  </code></pre>
  
  <p>I trying do like that</p>
  
  <pre><code>if(isset($_POST['new_ok'])){if(mysql_num_rows(mysql_query("SELECT name FROM db1 WHERE name= '$name'");) != 0){$result = mysql_query("INSERT INTO db1 (name) VALUES('".$name."')",$db);}else{echo "wrong";}}
  </code></pre>
  
  <p>But <code>mysql_num_rows always</code> return 1</p>