PHP display MySQL garbled related solution tips to share _php tutorial

Source: Internet
Author: User
Tags mysql in set set
PHP shows MySQL garbled problem 1. Using the phpMyAdmin operation MySQL database Chinese character display is normal, but the PHP page displays MySQL data when all Chinese characters have become the number.

Symptoms: Using phpMyAdmin to enter Chinese characters is normal, but when the PHP page displays MySQL data, Chinese characters become the number, and how many Chinese characters there are number. Many students are experiencing this problem, especially after installing the latest version of Appserv. For this reason many students abandoned PHP, modified to learn ASP.

Reason: There is no code in the PHP Web page to tell MySQL what character set to output Chinese characters.

★php display MySQL garbled solution: This is not garbled, as long as the PHP page header to add the following section of code to tell MySQL to UTF8 encoded output of Chinese characters can

 
  
  
  1. <?>
  2. You can also insert the above code snippet directly into the PHP code section of the Web page (i.e. remove both ends < ?? > No.). For example, if you use Dreamweaver to connect to a database, you can connect the code in the header
  3. < Add the code to the?> to turn it into
  4. < ?
  5. PHP require_once (' connections/connmessage.php ');
  6. mysql_query ("SET NAMES UTF8");
  7. ?>

Note: If your page encoding is gb2312, that is SET NAMES GB2312. But editors strongly recommend page encoding, MySQL data table character set, phpMyAdmin all unified use UTF8. Please see the 2nd section of the first chapter of PHP tutorial.

PHP shows MySQL garbled problem 2. An error occurred while entering data with phpMyAdmin, and no input or garbled characters were allowed

★php shows MySQL garbled solution: This is a setup issue. Please install the latest version of phpMyAdmin or Appserv, open the Phpmyadmin,mysql character set: UTF-8 Unicode (UTF8); MySQL connection proofreading should be utf8_unicode_ci When you create a new database, organize a column and select it as Utf8_unicode_ci. The web character set is also best chosen UTF8. UTF8 is the international standard coding, is the trend. How to change the page encoding please see this site PHP Tutorial chapter 2nd, section I.

PHP shows MySQL garbled problem 3. In this machine developed a good MySQL data table, in the native test everything is normal, but with the website space provider of phpMyAdmin upload but there is a problem, upload failed. Especially the use of foreign php space.

★php display MySQL garbled solution: First look at the phpMyAdmin character set set provided by the website space quotient, make sure that the data table you built is the same code as space. MySQL in foreign countries do not support gb2312, even the latest version of Appserv also does not support gb2312. If it is because the coding is not uniform, the data table can be rebuilt, of course, with the international standard UTF8.


http://www.bkjia.com/PHPjc/446269.html www.bkjia.com true http://www.bkjia.com/PHPjc/446269.html techarticle PHP Display MySQL garbled problem 1. Use phpMyAdmin to operate MySQL database Chinese characters display normally, but all Chinese characters have become the number when displaying MySQL data with PHP Web page. Symptom: Enter Han ... with phpmyadmin ...

  • 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.