Solved

mysql sql insert query language problem

Posted on 2013-05-29
6
431 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

856 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