November 2, 200817 yr Hi there here is my problem: Cyrillic characters are not correctly encoded in utf-8 when pulled from my MySQL database (I use phpmyadmin to deal with the data). The content of my tables is though displaying correctly in phpmyadmin, but once its called by php and entered on the webpage I got question marks. So next, I read several online comments that recommend using mysql_query("SET NAMES 'UTF8'"); , but when I did that I got weird characters like мобÐ. Here are more specs: Apache/2.2.9 (Unix) PHP/5.2.6 MYSQL 5.0.45 The database, the data (varchar), and the column are all in utf8_general_ci. So I guess I did everything I could, but I must be missing some function to deal with the data I send with my form so that it will be well UTF 8 encoded but I don't see what I should use. I need to come up with some answer before Monday. Help!!! Thanks for your help
November 2, 200817 yr Hi there here is my problem: Cyrillic characters are not correctly encoded in utf-8 when pulled from my MySQL database (I use phpmyadmin to deal with the data). The content of my tables is though displaying correctly in phpmyadmin, but once its called by php and entered on the webpage I got question marks. So next, I read several online comments that recommend using mysql_query("SET NAMES 'UTF8'"); , but when I did that I got weird characters like мобÐ. Here are more specs: Apache/2.2.9 (Unix) PHP/5.2.6 MYSQL 5.0.45 The database, the data (varchar), and the column are all in utf8_general_ci. So I guess I did everything I could, but I must be missing some function to deal with the data I send with my form so that it will be well UTF 8 encoded but I don't see what I should use. I need to come up with some answer before Monday. Help!!! Thanks for your help Have you tried setting it to utf8_unicode_ci set the database connection collation to the above. in the data you could set the collation to utf8_bin, or latin1_bin also check the encoding in yout html <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> hope this helps
November 2, 200817 yr Author Have you tried setting it to utf8_unicode_ciset the database connection collation to the above. in the data you could set the collation to utf8_bin, or latin1_bin also check the encoding in yout html <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> hope this helps Thanks for your answer, The database is set to utf8_general_ci. I haven't tried unicode_bin or latin1_bin. Will do that and see how it goes.
November 2, 200817 yr Author It still doesn't work and Monday is fast approaching. I tried your advice 1. database charset: utf8_unicode_ci collation: utf8_bin table charset: utf8 collation: utf8_general_ci column charset: utf8 collation: utf8_general_ci 2. database charset: utf8_unicode_ci collation: latin1_bin table charset: utf8 collation: utf8_general_ci column charset: utf8 collation: utf8_general_ci In previous attemps I had collation of everything set to utf8_unicode_ci html encoding is set to UTF-8 because there are other cyrillic characters embeded in the page. I don't think that iso-8859-1 would work. I tried that before. <meta http-equiv="content-type" content="text/html; charset=UTF-8"> Has anyone else had that problem? What am I doing wrong? Help...
November 3, 200817 yr I have seen this problem before, and on the few occassions I have seen it, it was due to text being pasted into html documents or database fields from other sources such as .txt files, word files etc. Pat
November 3, 200817 yr Author I have seen this problem before, and on the few occassions I have seen it, it was due to text being pasted into html documents or database fields from other sources such as .txt files, word files etc. Pat I am so thankful for all the help. Let me explain the process I went through. I received word docs with russian text, copied and pasted it into a text editor and saved it as utf-8 unicode/ plain text. Then c/p it into phpmyadmin. (Once I figure out the prototype for this website, I will automate this process). Should I do it differently?
November 3, 200817 yr I am so thankful for all the help. Let me explain the process I went through. I received word docs with russian text, copied and pasted it into a text editor and saved it as utf-8 unicode/ plain text. Then c/p it into phpmyadmin. (Once I figure out the prototype for this website, I will automate this process). Should I do it differently? My Russian is not up to scratch but I would imagine there are characters in russian that wont translate with the encoding you are using, are you translating the text first. Pat
November 3, 200817 yr Author Neither do I speak Russian. I am just the webdesigner who needs to find a way to make this cyrillic data work. Shouldn't it work once the Cyrillic is turned into unicode? BTW I just found a recent blog post that deals exactly with my problem. Did everything the she/he said in her/his post and still couldn't make it work. See also my post... http://www.tanzilo.com/2008/10/13/php-mysq...age/#comment-34
November 3, 200817 yr Neither do I speak Russian. I am just the webdesigner who needs to find a way to make this cyrillic data work. Shouldn't it work once the Cyrillic is turned into unicode? BTW I just found a recent blog post that deals exactly with my problem. Did everything the she/he said in her/his post and still couldn't make it work. See also my post... http://www.tanzilo.com/2008/10/13/php-mysq...age/#comment-34 Try this in your <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> Pat
November 3, 200817 yr Author I should have mentioned that in the beginning, but I am working on a mac unix server, so I don't think windows-1251 will work
November 3, 200817 yr I should have mentioned that in the beginning, but I am working on a mac unix server, so I don't think windows-1251 will work Sorry Cant be of more help Pat
November 3, 200817 yr Author I give up. The data is pulled from the database correctly when I change the entries to some English words they get displayed correctly. If I type Russian letters directly into the text field in phpmyadmin I still get мобÐ. The problem is something in the encoding for Cyrillic characters. Sniff!
November 4, 200817 yr Author Ok, I got the solution to my own problem and I hope this will help someone else. After hours of hair pulling I figured it finally out. In my PHP smarty code I had the htmlentities set. I removed the smarty code $smarty->register_modifier("variable","htmlentities"); and removed the following variable in my template files. {variable} and everything worked fine. I will read up on this, but here is a post that mentions this problem http://annevankesteren.nl/2004/05/unicode-support. Here is the php documentation http://us2.php.net/htmlentities In addition I had to add some code after initializing the database connection. $db = DB::connect("mysql://$dbuser:$dbpass@$dbhost/$dbname"); mysql_query(mysql_query('SET character_set_results=utf8'); Tired, but happy...
Create an account or sign in to comment