" to PHP; 2. Open the data and add "mysql_query("set names utf-8 ");"."/> " to PHP; 2. Open the data and add "mysql_query("set names utf-8 ");".">

Home  >  Article  >  Backend Development  >  What should I do if the PHP database cannot insert Chinese characters?

What should I do if the PHP database cannot insert Chinese characters?

藏色散人
藏色散人Original
2021-07-02 11:11:442216browse

Solution to the problem that Chinese cannot be inserted into the php database: 1. Add "f89a46a6a756f40d0e372e851e248fd7" to PHP; 2. Open the data and add " mysql_query("set names utf-8");".

What should I do if the PHP database cannot insert Chinese characters?

##The operating environment of this article: linux5.9.8 system, PHP7.1 version, Dell G3 computer

What should I do if the php database cannot insert Chinese characters?

php mysql cannot insert Chinese characters

Write PHP today to operate the MySQL database The program displays a question mark when inserting Chinese characters, as shown below:

| abcdef3233 | 123456  | abcdef3233@163.com   | ????????? | 2011-12-25 10:22:47 |

When directly operating the database under Linux, the display is normal. Later it was found that the page encoding and database encoding were inconsistent. Solution:

Add to the PHP program:

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

After opening the data, add:

 mysql_query("set names utf-8");

Of course, I use utf-8 encoding here. If you are using gb2312 Encoding, utf-8 needs to be changed accordingly.

Problem solved.

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of What should I do if the PHP database cannot insert Chinese characters?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn