Php writes mysql Chinese garbled characters. it's utf8.

Source: Internet
Author: User
Php writes mysql Chinese garbled characters. it is already utf8. at last, the php file edited by itljl at 2015-03-2010:59:23 is already a UFT8 system code. & lt; meta & nbsp; http-equivContent-Type & nbsp; contenttexthtml; & nbsp; charset php writes mysql Chinese garbled characters, which is already utf8

This post was last edited by itljl at 10:59:23

The PHP file is already a UFT8 code,





$ Conn = mysql_connect ("localhost", "test", "test ");
If (! $ Conn)
{
Die ('could not connect: '. mysql_error ());
}
// Mysql_query ("set test 'utf8 '");
Mysql_set_charset ("utf8", $ conn );
// Select a database
Mysql_select_db ("test", $ conn );

// Insert data to the table
Mysql_query ("insert into test (id, myusername)
VALUES (2, 'Chinese 2 ')");

// Mysql_query ("insert into user (id, myusername)
// VALUES (". intval ($ str_id).", ". $ str_name .")");

// Close the database connection
Mysql_close ($ conn );


Configure the database in phpmysql.


Why are you?

------ Solution ----------------------
Mysql_query ("set names utf8 ");

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.