This will mean that it has nothing got to do with the last database update/insertion. What you do is to echo the variables after every calculation from the moment you extract it from the database.
This will allow you to trouble shoot and know where the errors comes from..
e.g.
$sandy = $tommy + $andy;
echo $sandy;
$yoshi = $sandy $tommy $andy;
echo $yoshi;
and you trouble shoot from there.