Forum Moderators: coopster

Message Too Old, No Replies

apostrophesquotes causing problems

         

cantona

12:37 pm on Jan 20, 2009 (gmt 0)

10+ Year Member



Hi

I have a PHP5 website using a MySQL5 db. The character set on site and in the db is UTF-8.

However, I'm still getting some problems with apostrophes and quote marks. Especially the right and left sloping ones MS Word use!

I thought that by added the form tag accept-charset="utf-8" to my forms would convert them to a valid character. However, they are still getting into the database.

I would have thought there would be some sort of clean up function available, but I'm unable to find one. I'm thinking of writing a function with a list of mb_str_replace() and change them all to '

What does everyone else do? This must be a common annoyance.

enigma1

12:45 pm on Jan 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think is common, perhaps you should check the setting of magic quotes on your server for the php and then check the functions that store the records in the dbase. Normally mysql wrappers should be used to ensure some characters are properly escaped and the input is filtered, subject to the magic quotes setting.

dreamcatcher

1:21 pm on Jan 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi cantona,

You say that apostrophes and quote marks are causing problems, but you don`t say what the problems are. If the issue it with your query failing use mysql_real_escape_string [php.net] when you do your insert.

If you want to strip them or change them, just use str_replace [php.net].

Or was it something else that was the problem?

dc