?
Solved

How to insert UTF-8 characters into mysql 5.0 database running on Linux CENT OS

Posted on 2010-09-15
3
Medium Priority
?
704 Views
Last Modified: 2012-06-27
Documentation says utf-8 unicode is the default settings on Linux. Our MySQL server has default server and database character set settings set to UTF-8 Unicode and collation set to utf8-unicode-ci.
Whenever we try to insert records that contain Japanese characters they are displayed as boxes. For example,  trying to insert this  ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ in a query shows up as rectangular boxes.
Russian and Polish character are displayed correctly. If the default character set is UTF-8 why isn't MySQL displaying the characters properly? In the knowledge base we see where using a SET statement helped some people. However, that hasn't helped us. Any suggestion will be appreciated.

Thanks
0
Comment
Question by:WPSLNetops
  • 2
3 Comments
 
LVL 5

Expert Comment

by:SaigonJeff
ID: 33692589
Try resetting you table collation to ujis_japanese_ci

Here is a great write up on using Japanese characters in MySQL...
http://mysql2.mirrors-r-us.net/doc/refman/5.0/en/charset-cp932.html

Let us know how it goes.

Good luck.
0
 

Author Comment

by:WPSLNetops
ID: 33726492
Thanks SaigonJeff, but we need our collation to be utf8-unicode-ci.
0
 
LVL 5

Accepted Solution

by:
SaigonJeff earned 2000 total points
ID: 33727011
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8-unicode-ci'");


Here is an example:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname = "localhost";
$database = "dbname";
$username = "username";
$password = "password";
$dbname = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8-unicode-ci'");
?>
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

749 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