Chinese characters cannot be inserted into the database solution

Source: Internet
Author: User
Chinese characters cannot be inserted into database
This post was last edited by Kaixinmaitian on 2014-01-19 10:47:58

MySQL data is UTF8

Page format is: GB2312

Settings were made when joining the database: mysql_query ("Set names GB2312")

Normal display when reading database information, but "Chinese character field is blank and data field is normal" when adding record

If you use Iconv ("GB2312", "UTF-8", $keywords) the conversion of Chinese characters to UTF8 format and then increase the database is garbled, please expert guidance.

share to: more

1, confirm that the field to save the Chinese connection proofreading is utf8_general_ci, of course, GBK_GENERAL_CI is also possible

2, is mysql_query ("Set names GBK")
Instead of mysql_query ("Set names GB2312")
Because gb2312 word capacity is too small, GBK and Utf-8 peer

3, mysql_query ("Set names XXX") role is to inform MySQL: I want to use XXX code to pass the data
So it's absolutely wrong to make your own code conversion.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.