Home > Article > Backend Development > The php statement contains Chinese and cannot be queried
php statement contains Chinese and cannot be queried
We use PHP to view database data, but Chinese cannot be used. This problem is related to Our encoding format is related to the character format of the database and the page format. These formats must be the same and are all set to UTF-8. The following are the detailed steps to solve:
1. Check first The encoding format of the MYSQL database, then we first find the installation directory of the MYSQL data and find the my.ini file:
## 2. Open the my.ini file : Find the default-character-set and set it to utf8. There are 2 places to set in total
3. Then restart the MYSQL data and find Inside the service
4. Then set the encoding format of our web page to UTF-8
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5. Set it in the PHP file and set it to utf8
mysql_query("set names 'utf8'");For more PHP related knowledge, please visit
PHP中文网!
The above is the detailed content of The php statement contains Chinese and cannot be queried. For more information, please follow other related articles on the PHP Chinese website!