PHP is suffering from an echoXML file. how can this problem be solved?

Source: Internet
Author: User
PHP is suffering from an echoXML file. & lt ;? Php $ conn = mysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot; root & quot;); if (! $ Conn) {echo & quot; OK PHP is suffering from echo XML.
$ Conn = mysql_connect ("localhost", "root", "root ");
If (! $ Conn ){
Echo "OK ";
}
$ Query = 'select * FROM rcuset order by no desc ';
$ Result = mysql_db_query ("test", $ query );
Echo" ";
While ($ row = mysql_fetch_object ($ result )){
Echo" No> ";
Echo" ". $ Row-> ch ." ";
Echo" ". $ Row-> f ." ";
Echo" ";
}
Echo" ";
Mysql_free_result ($ result );
Mysql_close ();
?>
You can output strings at the beginning. However, the source file is in XML format.
Added the line header ("Content-type: text/xml ");
Prompt
-----------------------
The XML page cannot be displayed.
XML input cannot be viewed using the XSL style sheet. Correct the error and click refresh or try again later.


--------------------------------------------

An XML document can have only one top-level element. An error occurred while processing the resource 'http: // localhost/getXML. php. Row 2nd, Location: 2

Warning: Cannot modify header information-headers already sent by (output started at C: \ AppServ \ www \ ge...
------------------------
Then the header ("Content-type: text/xml") is removed ");
The result is no longer a string.

The tangle of cool

------ Solution --------------------
Because you output xml, you can view the source file.
------ Solution --------------------
You add the header ("Content-type: text/xml ");

Because there cannot be any output before the header.
This error is returned because the header ('content-Type: text/html; '); no output is allowed before the sending header, and no space is available. you need to set the header (...) remove the space, other output items, or put the header directly at the top of the program to ensure that there is no output. Echo print_r var_dump and other output formats
------ Solution --------------------
Check the code. Debug and print in one step to locate the problem. I will show you some solutions for your error on the Internet. Http://hi.baidu.com/xiaefun/blog/item/87fd5f82e96a3eaa0df4d2cb.html
------ Solution --------------------
I also encountered this problem. The problem generally occurs in the following aspects:
1. remove BOM
2. No other characters except XML
3, 4.?> There cannot be a line break or even a space after the end.
------ Solution --------------------
Menu bar-format-coded in UTF-8 without BOM format
------ Solution --------------------
Well .. Same as you
------ Solution --------------------
Discussion

Isn't this in Notepad format?

------ Solution --------------------
The code above is okay. You must have entered the wrong code.

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.