I'm looking up a value in a SQL table. The table is returning the value "text", but when I run a comparison on it I get false. Is there a reason this would return false?
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$valType = $row['valType']; //Result: "text"
if("text" === $valType) {
$result = "true";
} else {
$result = "false";
}
echo $result; //Result: "false"
}
Thanks to the help of @Rocket Hazmat, I found my issue by using var_dump($row['valType']). It was a case sensitivity issue.
In your code example $valType is not "text", it is something else. See below example.
This could be shortened like this: