I'm very confused. I have several "float" fields in a mysql database. They either have 0,1,3 or 5 as the value (default is set to be 0). If the value is 0, the field is "off" for my purposes. If it has 1, 3 or 5, it's "on". I was checking like this...
if ($row['field1'] == "0") {
$field1 = "off";
} else {
$field1 = "on";
}
But I noticed that the field in mysql WAS 0, yet it was returning "on".
So I removed the quotes, like this...
if ($row['field1'] == 0) {
$field1 = "off";
} else {
$field1 = "on";
}
And it correctly returned "off".
However, not all fields are behaving the same, even thought they are all floats.
After removing quotes, I removed the quotes in all the other float field checks, but now they are returning the opposite of what they should be.
In other words, sometimes the quotes seem to be necessary, sometimes not, when checking if it has a 0 in the field. But I know that shouldn't be the case.
So figured I'd start her by learning what the truly proper way is, with quotes around 0 or not?