MYSQLI error message in PHP is garbled

Source: Internet
Author: User
Tags utf 8

Error message when creating a database connection with PHP mysqli is garbled.

The code is as follows:


  
   

MySQL is not installed, just want to see MYSQLI error message when MySQL is not installed. And the results are as follows:

are garbled under chrome and IE11.

The charset in the HTTP response header by the Check tool is Utf-8, and the default settings for Chrome and IE11 are also utf-8. In addition, PHP files themselves and the default encoding settings for both Apache and PHP are utf-8.

The present speculation is the problem of mysqli itself, because the figure of garbled parts and the mysqli_connect_error() resulting garbled consistent.

The mb_detect_encoding($conn->connect_error) result of the detection code shows that the error message encoding is also utf-8.

How to solve?

No offense, but in view of the fact that many of the answers have not yet read the description of the question hastily, I decided to repeat the important thing:

No mysql! installed

No mysql! installed

No mysql! installed

I just want to know what the error message mysqli was getting without installing MySQL. However, this error message is actually garbled, so there is this problem.

Progress: Running in the console with the PHP interpreter will get the correct error message, and the discovery is in Chinese, as shown in:

This error message is provided by the network communication module of the Windows system (the error message is often seen in the log in the case of a proxy server misconfiguration), so it is Win10 to look at the pot.

The problem is still unresolved. Although it is Chinese, but tried to GB2312, GBK, GB18030 way display, also garbled, but garbled content is different.

Reply content:

Error message when creating a database connection with PHP mysqli is garbled.

The code is as follows:


  
   

MySQL is not installed, just want to see MYSQLI error message when MySQL is not installed. And the results are as follows:

are garbled under chrome and IE11.

The charset in the HTTP response header by the Check tool is Utf-8, and the default settings for Chrome and IE11 are also utf-8. In addition, PHP files themselves and the default encoding settings for both Apache and PHP are utf-8.

The present speculation is the problem of mysqli itself, because the figure of garbled parts and the mysqli_connect_error() resulting garbled consistent.

The mb_detect_encoding($conn->connect_error) result of the detection code shows that the error message encoding is also utf-8.

How to solve?

No offense, but in view of the fact that many of the answers have not yet read the description of the question hastily, I decided to repeat the important thing:

No mysql! installed

No mysql! installed

No mysql! installed

I just want to know what the error message mysqli was getting without installing MySQL. However, this error message is actually garbled, so there is this problem.

Progress: Running in the console with the PHP interpreter will get the correct error message, and the discovery is in Chinese, as shown in:

This error message is provided by the network communication module of the Windows system (the error message is often seen in the log in the case of a proxy server misconfiguration), so it is Win10 to look at the pot.

The problem is still unresolved. Although it is Chinese, but tried to GB2312, GBK, GB18030 way display, also garbled, but garbled content is different.

Is it normal for you to output Chinese in PHP in your environment?
Did you add it header('Content-type: text/html; charset=utf-8'); ?
Manually change chrome's code to try it?

I tried it on the computer, three conclusions: 1. Your PHP page is not encoded with the HTML CharSet Settings page for UTF8 because PHP is ultimately fed back to the browser or plain HTML. 2. The return is not a utf8, for example, the returned GBK, you set on the page is UTF8, and the browser is GB2312. 3. May be where you have a problem with the configuration and you did not find, and we can not see your computer and this related information, the problem bar, there is no need to blindly let everyone to try.

Set the browser code should be, should not be mysqli reason, and the wrong way

The MySQL database encoding you installed by default is GBK, it is recommended to change the default encoding to ensure that the front end and database encoding unity, if the set is not enough, it requires MySQL to query before executing set names utf 8 to ensure that the buffer content is UTF8 format

Did not see the author of the topic content is not installed in MySQL, so delete.
But actually it should be because the MYSQLND extension

Since it is the character set that is returned from the handshake, it should be related to the system character set to install MySQL first try it after installation specify the string UTF8

Database connection settings, plus set encoding settingsmysqli_query('set name UTF8');

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.