Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Dustin Scott
Courses Plus Student 7,819 PointsWhy MySQL displays other languages as question marks
Hi,
I have a bunch of russian text in the database and I want to print it in the web page with PHP. I did all the steps to print it and when I will echo the string it will be as "????? ???????? ? ?????" I changed the collation to utf_general_ci in the database and I added meta charset in the html page. Why this problem is appearing?
Thank you
2 Answers

Jacob Herper
94,150 PointsYou might want to try one of these charsets for MySQL: http://dev.mysql.com/doc/refman/5.0/en/charset-cyrillic-sets.html (I think cp1251_general_ci should work for Russian cyrillic) And windows-1251 for HTML.

Ken Alger
Treehouse TeacherDustin;
It has been a while since I have dealt with non-Latin text, but if memory serves there are a few things to the setup of the MVC system to ensure proper functionality.
Model
Make sure the database charset/coallition is UTF-8
.
View
When you render the content from the database in a view, make sure the Content-Type is text/html; charset=utf-8.
Controller
On the page you insert these russian characters ( the form, textarea ), make sure the encoding is UTF-8
, by setting Content-Type to text/html; charset=utf-8
. Enter in Russian text directly to the form input.
On the processing page that handles this form, which inserts it into the database, make sure to do SET NAMES utf8
so it's stored as UTF-8
before you insert the data, in a separate query beforehand.
What versions of MySQL/PHP are you using? Like I said, it has been a while since I have had to do this so things could have changed.
Ken