title: Simple MySQL UPDATE only affects certain rows
body: <p><strong>SOLVED</strong></p>
  
  <p><strong>Rows 1, 4, and 10 have a field with a single quote character in them, so I was SQL injecting myself. More reason to switch to prepared statements!</strong> </p>
  
  <p>I have a very simple bulk UPDATE query sent from my PHP form which, oddly enough, only affects certain rows. Rows 1, 4, and 10 doesn't get updated; but all other rows get updated.</p>
  
  <p>Here is the query:</p>
  
  <pre><code>$query = "SELECT * FROM SkillDescriptions";
  $result = mysql_query($query);
  
  for ($i=1; $i&lt;=mysql_num_rows($result); $i++){
  
      $skillKey = 'Skill' . (string)$i;
      $categoryKey = 'Category' . (string)$i;
      $descriptionKey = 'Description' . (string)$i; 
  
      $sql="UPDATE SkillDescriptions SET 
           Skill='$_POST[$skillKey]', 
           Category='$_POST[$categoryKey]', 
           Description='$_POST[$descriptionKey]'
           WHERE id='$i'
           ";
      $result2=mysql_query($sql);    
  
  }
  </code></pre>
  
  <p>I've got a parallel form that does the exact same PHP form processing as this one but has a different database table, which works properly: so the problem most likely lies in the database table (configuration?) and not the code.</p>
  
  <p>Why do only certain rows get updated, in a seemingly random pattern? </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Before:</p>
  
  <p><a href="http://i.stack.imgur.com/2hk2l.png" rel="nofollow">http://i.stack.imgur.com/2hk2l.png</a></p>
  
  <p>After: (I appended test to the columns)</p>
  
  <p><a href="http://i.stack.imgur.com/ObMn5.png" rel="nofollow">http://i.stack.imgur.com/ObMn5.png</a></p>