Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

705 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

15 Experts available now in Live!

Get 1:1 Help Now