0
I have a problem that I could not solve in php, I have a field varchar
in the MySQL
with accentuation, I rescue the same and use the htmlentities
for the string to have the correct accent.
I need to compare the variable coming from the bank and mark a radio field if the condition is true, but I’m not getting what I have and this:
Rescue of the variable:
$Motivo = htmlentities($row_DocContratacao['MotivoContratacao']);
Value comparison
<input type="radio" name="Motivo" id="motivo-4" value="Recontratação"<?php if ($Motivo=="Recontratação") echo ' checked="checked"'; ?> />
The amount redeemed is Recontratação
but the radio field is not marked.
You can also remove the accents and make the comparison without accents.
– Franchesco
Hello @Earendul, but I don’t understand why I couldn’t make the comparison with accent.
– adventistapr
the condition does not match because when applying
htmlentities
the comparison gets'Recontratação' == 'Recontratação'
, remove the call fromhtmlentities
should solve the problem– Pedro Sanção
possible duplicate of How to compare data with accents in the database?
– Franchesco
Hello @Sanction, in my case, with htmlentities I can rescue the variable with the correct accent, but I can’t compare it.
– adventistapr