How to store chinese characters in MySQL table?

Posted on 2007-10-07
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

    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

    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.

    Join & Write a Comment

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    754 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

    25 Experts available now in Live!

    Get 1:1 Help Now