4

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)

0

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I have added those lines, but im still getting the question marks
Make sure your php client is using utf-8 caracter set too, mysql_set_charset('utf8',$conn); See the manpage for this function.
When you open your database connection with mysql_connect() I presume, you need to be sure the client is using utf8. The db may be opening client connections to default ISO-8859-1 or some other non utf8 code page.
0

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.

Comments

0

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

2 Comments

My database and tables are already in the utf8 form, and i can see the non english letters in phpmyadmin table-browse area, only in my web page it is not showing - i included content-type utf8 also!
With firefox on the PHPmyadmin page do a right click -> Page information, you should have a window with the encoding. Now do the same with your PHP page and if it's not the same than Phpmyadmin it means you have an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.