A beginner just learned PHP and asked questions about Chinese garbled characters in SQL INSERT statements

Source: Internet
Author: User
A beginner just learned PHP and asked a question about Chinese garbled characters in SQL INSERT statements. PHPcode & lt ;? Php @ mysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot;) ordie (& quot; failed to connect to the MySQL database. & Quot;); a beginner just learned PHP and asked a question about Chinese garbled characters in SQL INSERT statements.
PHP code
  
  


Q: Chinese characters are garbled and English is normal. what should I do? PHP version 5.3.8 and MySQL version 5.5.16 ~~~

------ Solution --------------------
Mysql_query ("set names gbk ");
In addition, you need to change the file encoding to gbk encoding.
------ Solution --------------------
Discussion

Reference:

Unified encoding. Run mysql_query ("set names 'Your data table encoding'") before inserting '");

My data table code: gbk_chinese_ci
I changed the code:
PHP code
@ Mysql_connect ("localhost", "root", "") or die ("failed to connect to MySQL database. ");
Mysql_select_db (......

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.