Solved

mysql sql insert query language problem

Posted on 2013-05-29
6
426 Views
Last Modified: 2013-06-03
I have a Turkish character problem when use my insert query.
I see the table with unkown charcters when I use a Turkish character like Ö or Ü
what should I do?
0
Comment
Question by:Braveheartli
6 Comments
 
LVL 40

Expert Comment

by:Sharath
ID: 39205366
There is a solution provided in this link. Check this.

http://www.bothernomore.com/2008/12/16/character-encoding-hell/

extracted from the above page.

alter table TABLE_NAME modify FIELD_NAME blob;
alter database DATABASE_NAME charset=utf8;
alter table TABLE_NAME modify FIELD_NAME varchar(255) character set utf8;
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 39205439
Sharath_123 i doesn't work.
I have just tried.
0
 
LVL 23

Expert Comment

by:nemws1
ID: 39205517
try issuing this:

set character set 'utf8';

And then try Sharath_123's suggestion.
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 1

Author Comment

by:Braveheartli
ID: 39205537
My sql table looks like this...
Untitled-1.png
0
 
LVL 23

Expert Comment

by:nemws1
ID: 39206072
Ugh.  PHPmyAdmin.  Which *should* work correctly with UTF8.  Are you sure your data was imported correctly?  The same settings we've mentioned here need to be set when the data is loaded as well!
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39207411
There are, potentially, a lot of moving parts to this question.  Begin your learning adventure here.
http://www.joelonsoftware.com/articles/Unicode.html

Then read this PHP script.  You can see its output on my server.
http://www.laprbass.com/RAY_temp_braveheartli.php

<?php // RAY_temp_braveheartli.php
error_reporting(E_ALL);

// SEE http://www.experts-exchange.com/Database/MySQL/Q_28142046.html

$chr = 'Ö';
echo "CHARACTER $chr HAS STRLEN " . strlen($chr);

Open in new window

The fact that the script shows a string length of 1 for the $chr variable is significant.  I used copy/paste to recover that character from this EE web page and put it into my script.  If it has a string length of 1, it is not UTF-8 encoded.  The O-Umlaut would be a two-byte character in UTF-8.  This is probably something like ISO-8859-1 encoding.

Character encoding must be consistent throughout all of your processing, and that means that your text editor, your PHP scripts, your data base, and your generated HTML must all be correct and in consonance for you to get the correct output.

What I think I am seeing when I look at the phpMyAdmin image is a mix of UTF-8 characters and Western Latin characters.  I say that because the upper-case accented A occurs frequently in improperly encoded UTF-8 strings.  It is a symptom of taking a UTF-8 character and storing it in the form of a Western character set, where the two-byte UTF-8 character gets turned into two separate Western characters of one byte each.
http://filedb.experts-exchange.com/incoming/2013/05_w22/657154/Untitled-1.png

So my advice would be to check all elements of the character encoding and attempt to be consistent throughout.  If you're using PHP, you need to learn about how PHP handles character strings, and about how this is changing as PHP is modernized.  Some links tell how this works:
http://php.net/manual/en/language.types.string.php
http://php.net/manual/en/language.types.string.php#language.types.string.details

An important quote from the man page:  Using functions that can handle Unicode encodings is just the beginning. No matter the functions the language provides, it is essential to know the Unicode specification. For instance, a program that assumes there is only uppercase and lowercase is making a wrong assumption.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now