How to store chinese characters in MySQL table?

Posted on 2007-10-07
Medium Priority
Last Modified: 2013-12-13
I am having a textarea which i can store text in Mysql table. But when I try to enter chinese text, it will get stored as ???????????. The column is a text column with unicode encoding.
Question by:jtcy
1 Comment
LVL 21

Accepted Solution

nizsmo earned 2000 total points
ID: 20029892
What are you entering it in?

Following may be helpful:


mysql_connect ( 'localhost', 'user', 'pass' );
mysql_select_db ( 'my_database' );

// set utf8 unicode mode
mysql_query ( 'SET NAMES utf8' );  // This is the important line

// continue script...


Also if you wanted to display chinese characters you would need to have this in your html:
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />

Please let me know how you get on.

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 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