title: MySQL adds 2, unless I echo the variable in which case it adds only 1
body: <p>please excuse the terrible title!</p>
  
  <p>I have the following line of code:</p>
  
  <pre><code>$this-&gt;sql-&gt;mysqli-&gt;query(
      "UPDATE `threads` SET `views` = `views` + 1
      WHERE `id` = '".$this-&gt;thread['id']."'
  ");
  </code></pre>
  
  <p>One would expect this to add + 1 to views right? Well it doesn't. It adds 2!</p>
  
  <p>This isn't any kind of loop or anything.</p>
  
  <p>Anyway, I try this to fix it..</p>
  
  <pre><code>$views = $this-&gt;thread['views']++;      
  $this-&gt;sql-&gt;mysqli-&gt;query(
      "UPDATE `threads` SET `views` = '".$views."'
      WHERE `id` = '".$this-&gt;thread['id']."'"
  );
  </code></pre>
  
  <p>Again no luck, it still adds 2!</p>
  
  <p>Trying to debug further...</p>
  
  <pre><code>$views = $this-&gt;thread['views']++;      
  $this-&gt;sql-&gt;mysqli-&gt;query(
      "UPDATE `threads` SET `views` = '".$views."'
      WHERE `id` = '".$this-&gt;thread['id']."'"
  );
  echo $views;
  </code></pre>
  
  <p>With the code above, <code>$views</code> echos exactly what it should do and the row updates exactly how it should! The echo makes it work, I have no idea why and I don't want the echo.</p>
  
  <p>Can't get to the problem is this, I feel like someone is taking the piss.</p>
  
  <p>Regards</p>
  
  <p>Mic</p>
  
  <p>Edit: It turns out that it doesn't matter what is being echoed below version 1 above, it makes it work, but not without the echo</p>
  
  <p><strong>Edit in response to brian and extra clarification:</strong></p>
  
  <p>The follow code makes <code>views</code> add TWICE. (i.e., adds 2)</p>
  
  <pre><code>$this-&gt;sql-&gt;mysqli-&gt;query(
      "UPDATE `threads` SET `views` = `views` + 1
      WHERE `id` = '".$this-&gt;thread['id']."'"
  );
  </code></pre>
  
  <p>The following code...</p>
  
  <pre><code>$this-&gt;sql-&gt;mysqli-&gt;query(
      "UPDATE `threads` SET `views` = `views` + 1
      WHERE `id` = '".$this-&gt;thread['id']."'"
  );
  echo 'foo';
  </code></pre>
  
  <ul>
  <li>echos 'foo' ONCE and</li>
  <li>adds 1 to view (ie works properly)</li>
  </ul>