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 ");