PHP Replace special characters before MySQL insertion

If you are working with MySQL database (UTF-8) and handle input that is being copied from other sources- you may run into issues with special characters such as ellipses, long dashes, and special quotes.

Inserting these characters without addressing them can lead to nasty results later on, like this: 


Here is a useful function that replaces the most common special characters with their UTF equivalents

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>