I have a field in my mySQL db table of type decimal (15,4)
I've never experienced this before but if the value is 0.0000 my PHP if statement is returning true!
As a sanity check I even did:
if(0.0000) echo "Hello World";
And sure enough, Hello World echo'd out. What the hell is going on? Anybody got any ideas?
If it's a float value coming out from DB it will be treated like a string, not like a numeric value. You can try something this:
if(floatval($value) > 0) { ... }
Where $value
contains the value from DB.
I think the problem is you got a string "0.0000"
from db but not 0.0000
.
Try again with:
if ((int)$your_value) echo "Hello World";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With