mysql_query("UPDATE stuff SET lol=lol-5 WHERE id>0 and lol> 0;"); field lol is tinyint and unsigned. When lol is 1 and it takes off 5, it goes explodes and jumps to 4 trillion. Why, how, why?
Sorry, I meant to say UNSIGNED. It is already unsigned. Also the problem is not that it goes negative, the problem is that it jumps to 4 TRILLION, it's the maximum amount tinyint can old I guess. Any cure?
Chances are you're going to want to check the balance before performing that query so you can react to insufficient funds/points/wtc errors. Or, switch to a signed int. It happens because the bytes used to store the numbers are read differently in signed VS unsigned. the bits that would indicate -1 in an signed int would indicate the upper bounds of an unsigned. Hence the reason you can store twice as many positive numbers in an unsigned in than a signed one.