Home  >  Article  >  Backend Development  >  PHP reads mysql garbled code

PHP reads mysql garbled code

藏色散人
藏色散人Original
2019-10-15 10:43:062241browse

PHP reads mysql garbled code

Solution to php reading mysql garbled code

Problem:

The database is in Chinese. Searching the database on the web page displays the following:

img/??.png

The data in the database is:

img/mine. png

Solution:

First of all, if your php web page is UTF-8

After connecting to the database, insert the following code:

$program_char = "utf8" ;
mysqli_set_charset( $con , $program_char );

If you use other formats, the same is true, just change $program_char

At this point: the web page can finally display the Chinese characters in the database.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of PHP reads mysql garbled code. 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
Previous article:How to patch phpNext article:How to patch php