CodeIgniter : form input set_value cause " to become & quot
Problem :
A string retrieved from database contains "
and when you try to display the string with Form Helper's set_value()
function. The "
becomes "
How to fix this problem?
Solution :
By default the set_value()
function will escape the value. (see http://www.codeigniter.com/userguide3/helpers/formhelper.html#setvalue) and this will cause "
to become "
Therefore, to fix this problem, turn off the HTML escaping by setting false
in the 3rd parameter of the set_value()
function.
From
set_value('sometitle', $sometitle);
to
set_value('sometitle', $sometitle, false);
This should prevent the "
to become "
now after disabling the default HTML escaping.
Reference :
http://www.codeigniter.com/userguide3/helpers/formhelper.html#setvalue
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8k Javascript : How to check a browser's Do Not Track status?
+16.5k Golang :Trim white spaces from a string
+6k AWS S3 : Prevent Hotlinking policy
+6.6k PHP : Shuffle to display different content or advertisement
+13.7k Golang : Read XML elements data with xml.CharData example
+88.6k Golang : How to convert character to ASCII and back
+9.6k Golang : Accessing content anonymously with Tor
+16.6k Golang : Execute terminal command to remote machine example
+10.1k Golang : Channels and buffered channels examples
+9.4k Golang : Generate random Chinese, Japanese, Korean and other runes
+23.1k Golang : Test file read write permission example
+7.8k Golang : Command line ticker to show work in progress