title: Update MySQL Statement from CodeIgniter
body: <p>I'm having a problem with this query for some reason:</p>
  
  <pre><code>$this-&gt;db-&gt;query("UPDATE schools SET name = '$name', pop = '$pop', details = '$details', numteachers = '$numteachers', recess = '$recess', equipment = '$equipment' WHERE id = '$schoolid'");
  echo $this-&gt;db-&gt;affected_rows(); 
  </code></pre>
  
  <p>For some reason affected_rows prints 0 but there's no errors with the query. When I look in the database the row id has not been affected. I escape all the inputs before the query like this:</p>
  
  <pre><code>$name = mysql_real_escape_string($_POST["schoolname"]);
  </code></pre>
  
  <p>With all of the inputs, an example query with real inputs looks like this before its executed:</p>
  
  <pre><code>UPDATE schools SET name = 'Jefferson County Public School', pop = '2,345', details = 'Lorem Ipsum is simply dummy text of the and typesetting industry.', numteachers = '2 Te', recess = '40 mins', equipment = 'Gym, Climbing Frame, Goal Posts, Track' WHERE id = '1'
  </code></pre>
  
  <p>All of the columns are already populated under row id 1, this is just new data. id is an int, primary key and auto_incrementing.</p>
  
  <p>Any advice would help, thank you!</p>