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 (......