Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 11:56:06 AM

Pages: [1]   Go Down
  Print  
Author Topic: MySQL - Turkish character encoding issue  (Read 1400 times)
monart
Newbie
*
Offline Offline

Posts: 2


« on: November 12, 2011, 03:20:28 AM »

Hi,

I have the following issue with MySQL.

Turkish text which is read from my table looks like this: http://www.oyunbazlar.com/boardgames.php.
As you see, all special Turkish characters are replaced by "?"

I tried a lot of combinations on my table, i.e. CHAR/VARCHAR/TEXT, even BINARY with latin5_turkish_ci/ucs2_turkish_ci and utf8_turkish_ci, but it does not solve the problem - sometimes more funny characters than quotation marks  appear, though.

The problem is definitely with MySQL, as text read from other sources is displayed normally.
I tried also one of the solutions given in this forum and added "@mysqli_options($conn, MYSQLI_INIT_COMMAND, "SET NAMES 'utf8_turkish_ci' ");" to my coding, but it did not worked either.

I didn't had this problem before, it appeared after I have made some modifications to my table, but I don't remember which.

Thanks for any help on this issue.

Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5215



« Reply #1 on: November 12, 2011, 06:13:29 AM »

Your page is being displayed in UTF-8, so any text coming out of the database must be UTF-8 encoded. When you say you changed the database or table encodings, did you do it in such a way as to not only change the registered encoding/collation, but also actually translate the existing data? It sounds like you didn't, and you still have Latin-n encoded text in the database. Those accented characters (text x80 through xFF) are invalid UTF-8 characters and will give you an error (?-in-diamond).

If you now have a mixture of UTF-8 encoded and Latin-n encoded data in your database, you've got a mess that you'll have to manually clean up using phpMyAdmin. If it's all one encoding (but not UTF-8), I believe that there are tools in phpMyAdmin (and maybe in your application) to convert and translate the existing text.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
monart
Newbie
*
Offline Offline

Posts: 2


« Reply #2 on: November 12, 2011, 10:08:46 PM »

Dear Mr. Phil,
Thank you for your prompt answer.
I have cleared all the "latin/utf-8" mess as you have suggested and put "utf8_turkish_ci" as default wherever possible.
I have also added the line: "mysql_query("SET NAMES utf8");" after the commands accessing my database.
Now, everything seems to work smoothly.
Logged
Hobbittr
Newbie
*
Offline Offline

Posts: 1


« Reply #3 on: April 14, 2012, 12:12:11 AM »

I also had this problem and the LunarPages tech support staff and I went through several versions of my trouble ticket before I got it straightened out. I had a mess in MySQL so I use Reset to default values.

I changed one item using File manager >> /www  >> wp-config.php
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

I CHANGED IT TO:
define('DB_COLLATE', 'utf8');

I use WordPress and I also changed the character encoding in the WordPress dashboard under Settings >> Reading "Encoding for pages and feeds" to UTF-8

Now it works great  Very Happy

Logged
Pages: [1]   Go Up
  Print  
 
Jump to: