How can I deal with a quote in data that has to be there?
This javascript statement works fine until city name is "ST JOHN'S". We are not able to change the change the city name in database -or- use a more reliable key.
$('#map_output').html('<p><img src="img/map/<?=$CITY_OUT?>_map.PNG" width="600"></p>')
Use htmlspecialchars().
EDIT: you use it (sorta) like json_encode:
<?=htmlspecialchars($CITY_OUT, ENT_QUOTES)?>
But htmlspecialchars is more semantic - json_encode is about generating JSON (internal, data representation), not about presentation.
Nick Craver is right though - it'll also work.
Edit: need ENT_QUOTES for rendering " ' " correctly...
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