Inserts / Updates Occuring Twice
<p>I have the following code:</p>

<pre><code>while(1){
    $r = rand(0,9); 
    echo "running...";

    if($current_item  &gt;= $array[$r]['limiter']){
        $foo = $foo;
        $bar = $bar;
        mysql_query("INSERT INTO db (type, hp) VALUES ('$foo', '$bar')");
        echo "done.";
        break 1;
    }
}
</code></pre>

<p>When I run this I'll get <code>"running..."</code> echoed out once or a few times (which is expected) and <code>"done."</code> echoed out once, as expected.</p>

<p>Yet two entries will be inserted into the database with different information hinting that the entire if statement ran twice.</p>

<p>Has anybody run into this before? Is there something happening that I'm not seeing here? Any ideas how to fix this?</p>

<p>I have a similar problem with Updates, they too update twice and they're completely separate from a loop.</p>

<p><strong>Edit:</strong> just to try to clarify, </p>

<ul>
<li><p><code>$current_item</code> does change but in the context of the loop it is constant.</p></li>
<li><p><code>$array[$r]['limiter']</code> references a multidimensional array. </p></li>
<li><p>Neither of these should affect the loop itself, it's just a condition that has to be met to do anything.</p></li>
</ul>
