Solved

mysql sql insert query language problem

Posted on 2013-05-29
6
423 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

744 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

10 Experts available now in Live!

Get 1:1 Help Now