title: Insert on duplicate key update didn't update, instead insert new value
body: <p>I have table with 4 row, 1 Primary key with auto-increment , the row is check_id.. </p>
  
  <p>What I want to do is <em>insert a new data if no data exist and update data based on id if it exist.</em></p>
  
  <p>I already use:</p>
  
  <pre><code>insert into checklist (check_pos,check_ok,check_code) values ('$names','$names','$code')  on duplicate key update check_ok = '$names'
  </code></pre>
  
  <p>But this only insert a new value. </p>
  
  <p>Instead, I tried to change the <code>check_id</code> to <em>unique key</em> and it also the same,</p>
  
  <p>Is there something wrong with my update query or my table?</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;?php
  $ew = mysql_query("select * from pos_unit where pos_unit_name like '%Director%'");
  $row = mysql_num_rows($ew);
  while($eq = mysql_fetch_array($ew))
  {
  $pos = $eq['pos_unit_name'];
  $checklist = mysql_query("select * from checklist where check_ok = '$pos'");
  $excheck = mysql_fetch_array($checklist);
  $poss = $excheck['check_pos'];
  ?&gt;
  &lt;li&gt;
  &lt;div class="form_grid_12"&gt;
  &lt;label class="field_title" id="actual"&gt;&lt;?php echo $eq['pos_unit_name']; ?&gt;&lt;/label&gt;
  &lt;div class="form_input"&gt;
  &lt;input type="hidden" name="id[]" value="&lt;?php echo $excheck['check_id']; ?&gt;"&gt;
  &lt;input name="position[]" class="checkbox" type="checkbox" &lt;?php if($pos == $poss) echo "checked='checked'"; ?&gt; value="&lt;?php echo $eq['pos_unit_name']; ?&gt;" style="opacity: 0;"&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/li&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>and this is the php code..</p>
  
  <pre><code>include 'config.php';
  
  
  $code = $_POST['code'];
  $id = $_POST['id'];
  //$dist = $_POST['selectdistarg'];
  $check = $_POST['position'];
  //$input = $_POST['selectinp'];
  //$eval = $_POST['selecteval'];
  
  
  foreach($check as $index =&gt; $names)
  {               
      $up = mysql_query("insert into checklist (check_pos,check_ok,check_code) values ('$names','$names','$code') on duplicate key update check_ok = '$names'") or die (mysql_error());
  
  }
  </code></pre>