Chinese characters inserted in PHP

Source: Internet
Author: User

The garbled code caused by encoding has been a lot of time. I do not know what went wrong. It is clear that the PHP file encoding is consistent with the MySQL encoding. However, the implanted data is indeed garbled Chinese characters. Adjustment
The results of multiple encodings are the same. In the end, this problem was solved by using mysql_query ("set names 'gbk.

Garbled characters are not declared

<?
$ Conn = @ mysql_connect ("127.0.0.1", "root", "") or die ("connection error"); // ip
Mysql_select_db ("www", $ conn );//
$ SQL = "insert into test (ID, uid, regdate, remark) values (null, 'Liu yife', now (), 'start ')";
Mysql_query ($ SQL, $ conn );
?>


Add: mysql_query ("set names 'gbk'"); solve the garbled Problem

<?
$ Conn = @ mysql_connect ("127.0.0.1", "root", "") or die ("connection error"); // ip
Mysql_select_db ("www", $ conn );//
Mysql_query ("set names 'gbk '");
$ SQL = "insert into test (ID, uid, regdate, remark) values (null, 'Liu yife', now (), 'start ')";
Mysql_query ($ SQL, $ conn );
?>

 

 

 

 

What I used to find on the Internet
Set names 'gbk'. I wrote an error and found it today as mysql_query ("set names 'gbk '").

 

Http://hi.baidu.com/laoshiaaa/blog/item/dea3256774896d2faa184c6e.html/cmtid/64aa46ac89442a064a36d67e

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: info-contact@alibabacloud.com 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.