How to display non-english characters from mysql database using php?

I created a web page that requires non-English style information storage. I created a db and a table using PHPMyAdmin with charset utf8 and collate utf8_general_ci, and I enter some sample data into this table, in the viewport of PHPMyAdmin I can see non-English characters, but when I request this table data using php, it displays as question sign (something like that)

+4
source share
3 answers

Try adding this to your headline:

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

See this page for different ways to do this on different types of content.

+2
source

How do you determine if the result of your request is malformed utf8? If you display it on a website, remember that you have a well-formed metaconstruction in the main 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, the browser may try to display it using a different character encoding.

In general, PHP handles utf8 characters pretty well. Ofc some things need to be considered, here is a good summary about it .

0
source

If the rest of your database is not in UTF8, and only this table is in UTF8, you can either change the encoding in the header of your HTML, or use utf8_decode () to decode the utf8 string.

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

0
source

All Articles