PHP inserts SQL Chinese garbled characters! Solution
Source: Internet
Author: User
PHP inserts SQL Chinese garbled characters! The data I want to insert is obtained from the URL and the encoding is consistent (PHP page and SQL database). after UTF-8 data is inserted, it is garbled in phpmyadmin. Except Chinese characters ., I don't know if the following statement is not added when you write data to the database. you 'd better try PHP to insert Chinese garbled characters in SQL!
The data I want to insert is obtained from the URL, and the encoding is consistent (PHP page and SQL database), both of which are UTF-8
After the data is inserted, check that the data in phpmyadmin is garbled.
Except for Chinese characters.
------ Solution --------------------
I don't know if the following statement does not exist when you write data to the database. you 'd better give it a try.
Mysql_query ("set names utf8"); // or set names gbk/gb2312
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.