CodeIgniter Forums
Preventing conversion to entities for special characters, e.g. ' and &, when writting to db (utf8 & mysql) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Preventing conversion to entities for special characters, e.g. ' and &, when writting to db (utf8 & mysql) (/showthread.php?tid=16129)



Preventing conversion to entities for special characters, e.g. ' and &, when writting to db (utf8 & mysql) - El Forum - 02-25-2009

[eluser]Ollie Rattue[/eluser]
Hey,

I am having a few issues with charsets and mysql. If I enter "a second set of test's for entity & issues" in a input field which is then inserted into a db I end up with "a second set of test's for entity & issues".

The db collation and charset is set to utf8 unicode. So thats all fine and I except it to work like that and this is normally useful as printing anything pulled from the db in a webpage will display correctly.

However I need to be able to export the data to csv/excel spreadsheet and Phpmyadmin will leave the entities in there when it extracts. If i enter something like "i can && '''''''''''' " via phpmyadmin it stores the values without the entities which makes me think that this is a php/ci encoding before it reaches the db.

How can I prevent values such as & and ' being converted to an entity?


Preventing conversion to entities for special characters, e.g. ' and &, when writting to db (utf8 & mysql) - El Forum - 02-25-2009

[eluser]Ollie Rattue[/eluser]
As a follow up it is as if it is being run through htmlentities() before being saved into the db. I don't know if this is just what happens normally with utf-8 or whether ci or some setting I have is doing this.


Preventing conversion to entities for special characters, e.g. ' and &, when writting to db (utf8 & mysql) - El Forum - 02-26-2009

[eluser]Ollie Rattue[/eluser]
Finally I am using the active record class. Would this be converting human readable characters to entities before saving to the db?