5 hours to solve the weird php--. "Image xx because of its own mistakes can not be displayed" problem _php tutorial

Source: Internet
Author: User
Tags fiddler2
Yesterday, we finally migrated a customer's website to a virtual host, with a hopeful typing URL. A swish, the website is very easy to be opened. The heart that happy Ah ~ ~ ~, how the product pictures are not displayed. A block is blank. typed img src corresponding address to see what's going on? The results show the following effect:

IE this is the case:

There is no way to start a lengthy commissioning process. The steps to resolve are as follows:

1. Is the function code error: Follow the keyword image ... Because of its own mistakes can not be displayed, and quickly Google's several solutions.

Header ("Content-type:image/png"); This code is preceded by Ob_clean (); Clear output

Add Ob_clean () to the corresponding code location;

The results of the run didn't change.

PS: In order to locate the error, in advance with the echo step-by-step output debugging for a long time, only to locate the specific code.

2. Think: Why in the local good, pass up on the wrong? is not an environment configuration issue.

Local environment Xamp, server Environment: Windows + IIS7.5.

In order to compare the similarities and differences of the results returned by the server, it is decided to use Fiddler2 to track local access to the same file and to the server accessing the same file.

Open the Fiddler2 and quickly locate the results.

Test Address:

A, http://www.server.net/index.php?ac=public&at=zoom&filename=upfile%2F2011%2F08%2F30%2F20110830222415_ 540.JPG&W=&H=120&ISZOOM=1B, Http://localhost:90/index.php?ac=public&at=zoom&filename=upfile %2f2011%2f08%2f30%2f20110830222415_540.jpg&w=&h=120&iszoom=1

The server returns the result:

Local return Result:

The similarities and differences are: the server file header more than one< span="">

What is this? To continue the search, the result is a BOM header for UTF8. That is, there is a BOM header in the file returned by IIS.

UTF8 Universal knowledge See: http://blog.csdn.net/hiruyue/article/details/8747221

3. Start checking that the file was turned into a UTF8 with a BOM header, and then found a PHP version of the detection BOM header code, saved as PHP files, to the server. Quickly locate the results, the system configuration file is changed to a file with the BOM header.

At this time, it is remembered that after uploading the website with FTP, the configuration file was modified using the FTP-brought editing tool. It was modified with Notepad. So, hurry to re-download the configuration file, with notepad++ change the file type to UTF8 without BOM, save, upload, access. The website finally returned to normal.

Look at the time, 5 hours have passed.

PS: In the second step, you also see that IIS sends an ICO file stream before sending the picture binary stream, which also results in an error.

Conclusion:

After the modification was completed, the Orain Brothers ' article was found. His problems are similar to mine. PHP uses streaming to download files and UTF-8 BOM issues

Summarize:

1. If you are having problems, think about the reasons before you solve them. Otherwise it is easy to tangle in the debug code.

2. Multi-Search

http://www.bkjia.com/PHPjc/440234.html www.bkjia.com true http://www.bkjia.com/PHPjc/440234.html techarticle yesterday, we finally migrated a customer's website to a virtual host, with a hopeful typing URL. A swish, the website is very easy to be opened. The heart that happy Ah ~ ~ ~, how to produce ...

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