开发者

PHP Filter for special characters before passing to sql database

开发者 https://www.devze.com 2023-01-15 15:50 出处:网络
How can I have my 开发者_高级运维code replace the body text rather than just \"returning\": if($body == \"Garçon\")

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

0

精彩评论

暂无评论...
验证码 换一张
取 消