Solved

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

Posted on 2010-09-15
3
675 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 500 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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