Simple MySQL returning unexpected values? [closed]-Collection of common programming errors

First of all, start by initializing your variables. Just in case.

$cashset = 0;
$scash   = 0;
$ecash   = 0;
$current = 0;

Then run the loop

while ($row=$resultzero->fetch_assoc()) {
    $cashset = $row['cashset']; // value 0
    $scash = $row['scash']; // value 0
    $ecash = $row['ecash']; // value 0
    $current = $row['current']; // value 0
    // DEBUG
    print "Read row: ($cashset,$scash,$ecash,$current)\n";

}

Then use comparison, as you already tried (don’t know why it didn’t work — I’m betting it had something to do with missing initialization)

if ((0 == $cashset) && (0 == $scash) && (0 == $ecash) && (0 == $current))
{
    $firstTime = 1; // var_dump($firstTime) = NULL
} else
{
    $firstTime = 0; // var_dump($firstTime) = NULL
}

The (0 == $variable) instead ($variable == 0) for comparisons is a pet trick of mine, so that if you mistakenly forget a = sign it will ensure you get an error, instead of the instruction becoming an assignment.

Also, verify that you are not retrieving more than one row, since the last row will overwrite the first. The code above dumps each row to screen when it is loaded for debug purposes.