echoed variable and non-echoed appear to give different results
<p>Do not know where to turn because this doesn't make sense to me, here is my function:</p>

<pre><code>function setLevels($db, $last, $time, $c) {
$db-&gt;setQuery("SELECT health, energy, ammo, maxHealth, maxEnergy, maxAmmo, energy_time FROM sl_user WHERE userid = '$c'")-&gt;upit();
$res = $db-&gt;getRow();
$curr = $res['energy'];
$max = $res['maxEnergy'];
$nrgtime = $res['energy_time'];
$chunks = floor(($time - $last)/180);
if ($curr &lt; $max) {
    if (($curr + $chunks) &gt; $max) {
        $curr = $max;
    } else {
        $curr += $chunks;
    }

    if ($curr &lt; $max) {
        $leftover = ($time - $last) % 180  + $nrgtime;
        echo $leftover;
        $db-&gt;setQuery("UPDATE sl_user SET energy = $curr, last_access = $time, energy_time = $leftover WHERE userid = '$c'")-&gt;upit();
    } else {
        $db-&gt;setQuery("UPDATE sl_user SET energy = $curr, last_access = ".$time.", energy_time = 0 WHERE userid = '$c'")-&gt;upit();
    }
} else {
    $db-&gt;setQuery("UPDATE sl_user SET last_access = ".$time.", energy_time = 0 WHERE userid = '$c'")-&gt;upit();
}
</code></pre>

<p>}</p>

<p>Now my problem is here:</p>

<pre><code>if ($curr &lt; $max) {
        $leftover = ($time - $last) % 180  + $nrgtime;
        echo $leftover;
        $db-&gt;setQuery("UPDATE sl_user SET energy = $curr, last_access = $time, energy_time = $leftover WHERE userid = '$c'")-&gt;upit();
    }
</code></pre>

<p>When I echo $leftover it shows me the value and enters that value into the database and everything seems fine.  When I remove the echo $leftover;  line it always enters zero into the energy_time field.  I cannot echo because I am generating XML output later on.</p>

<p>It makes no sense to me...</p>
