0

Every once in a while I run into this problem and finally decided to consult the experts. :) I insert foreign characters (Czech letters) into my MySQL database and see them there. They look fine. But when I try to retrieve them using PHP they come out with question marks on my website. Can someone tell me how to fix this? I use the charset utf-8 on the website (the characters on my website are all Czech) and I tried changing the Collation of the columns to different charsets. Such as utf-czech_ci or utf-general_ci and they still come out with question marks. I'm not sure if this is a MySQL problem or a PHP problem or an HTML problem, but I'm hoping someone else might know. Thanks.

4
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by Pado
0

Sounds to me like an HTML problem, if you can see the characters correctly in, say, phpadmin, that would mean that the database is storing and retrieving them correctly.

Your HTML code has to tell the browser which character set it is using, a line in the <head> section such as this

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

might help. (the xhtml+xml bit may not be applicable to your site, you may have to investigate the alternatives).

Of course, if your site is already correctly displaying utf-8 characters (characters which did not come from mySql), then probably the html is not at fault...

Edited by Simon Tite: afterthought

0

Check if executing:

SET names utf8

after connecting to the database will fix the problem.

0

Yes. Apparently this is an MySQL bug, according to this link: http://bugs.mysql.com/bug.php?id=10812

Thank you all. The "SET NAMES 'UTF8'" call immediately before my SELECT call worked like a charm. :icon_smile: Thank you, again. I've been struggling with this for ages.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.