title: wrong result when using assignment operators in codeigneter
body: <p>I'm having trouble when calculate grand total result from database <code>mysql</code>. I use <code>codeigneter</code> and <code>newbei</code>.</p>
  
  <p>Here is my db:</p>
  
  <pre><code>selldate | sell
  --------------
   9 2014  |  20
  10 2014  |  25    
  11 2014  |  15
  </code></pre>
  
  <p>
  
  <pre><code>$n2 = -1;
  
  $selling = $this-&gt;db-&gt;query("select sell as Y , date_format((selldate),'%M %Y') as month  from selling where id='$id' and selldate between '$dt1' and '$dt2'");
  
  foreach ($selling-&gt;result() as $row){
      $u = $n2++;
      $t = $u*2+1;
      $yt = $row-&gt;Y * $t;
      $t2 = $t*$t;
      $r = 0;
      $r += $yt;
      $w = 0;
      $w += $t2;
      ?&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;?php echo $row-&gt;month;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $row-&gt;Y;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $t;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $yt;?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $t2;?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;?php 
  
      }; ?&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;Grand Total&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo "Grand Total is $r";?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo "Grand Total is $w";?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>The problem is in <code>$r += $yt;</code> and <code>$w +=$t2</code>; it calculates the grand total for the table. </p>
  
  <p>When i used <code>$r=0;</code> and <code>$w=0;</code>, then i get wrong result for grand total, but when i delete <code>$r=0;</code> and <code>$w=0;</code> just use <code>$r+=$yt</code> only i get <code>true</code> result for grand total, but there have a error message</p>
  
  <blockquote>
    <p>Severity: Notice
    Message: Undefined variable: r</p>
  </blockquote>