PHP Filter for special characters before passing to sql database
How can I have my 开发者_高级运维code replace the body text rather than just "returning":
if($body == "Garçon")
return;
Also, since == is looking for exact string of text, how do I make it look for the body containing "Garçon"?
Essentially, I'm trying to build in a filter to change "Garçon" to "Garcon" since the special "ç" character comes up "null" in my database.
Thanks for your help.
You don't have to filter anything, nor replace any symbols.
Just setup your database to use utf8 encoding.
if your database is fresh new, create your tables with CHARACTER SET=utf8
option.
and add to your PHP scripts this call, right after db connect:
mysql_set_charset("<encoding>");
where <encoding>
is the actual encoding of your pages
精彩评论