开发者

How do i display non english characters form mysql database using php?

I created a webpage, which require to store information in non English character. I created db and table using 开发者_开发问答PHPMyAdmin with charset utf8 and collate utf8_general_ci, and I enter some sample data into that table, in PHPMyAdmin browse area i can see the non english characters, but when i query those table data using php, it is showing like question mark(????? like that)


Try adding this in your header:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

See this page for different ways of doing this on different content types.


How do you determine that the result of your query isn't properly formed utf8? IF you display it on a website, please remember to have a properly formed meta-construct in your head-section, something like this:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

or, another way to format it in php...

<?
...somecode...
header ('Content-type: text/html; charset=utf-8');
...morecode...

Otherwise your browser might try to display it using a different character encoding.

All in all PHP handles utf8-characters pretty good. Ofc some things have to be considered, here's a good summary about this.


If the rest of your DB is not in UTF8 and just this table is in UTF8 you can either change the charset in the head of your HTML or use utf8_decode() to decode the utf8 string.

http://us.php.net/manual/en/function.utf8-decode.php

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜