|
Posted by Erwin Moller on 09/28/04 12:01
João Morais wrote:
> Hi there guys,
>
> My doubt is, what's the best way of storing text into a mysql
> database, if the text has special characters.. imagine iso-8859-1.
>
> Should I convert the text using htmlentities and then put it into
> database, and later when I will retrieve it I should use the reverse
> process.
>
> What's the best way of doing this?
>
> Thanks in advance.
Hi,
I think it is easier to store the text raw in the db, and when
displaying it in a browser, use htmlentities.
(Of course, make sure you escape the text before inserting to avoid SQL
injection, eg via mysql_real_escape.)
In my opinion that is the cleanest way to store data, and you can also
use the data for other purposes, eg searching without having to worry
about changed characters because of the htmlentities.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|