PHP has a echo xml torture crazy brother, how to solve

Source: Internet
Author: User
PHP has an echo XML that's torturing crazy brother.
$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 ();
?>
The string can be output at first. But the view source file is in XML format
Added a row header ("Content-type:text/xml");
Just prompt
-----------------------
The XML page could not be displayed.
XML input cannot be viewed using XSL style sheets. Please correct the error and click the Refresh button, 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 '. Line 2nd, Location: 2

Warning: Cannot modify header information-headers already sent by (output started at C:\AppServ\www\ge ...
------------------------
Then the header was removed ("Content-type:text/xml");
It turns out there's no strings.

Tangled, gothic, and sore.

------Solution--------------------
Because you are outputting XML, you can see the source file.
------Solution--------------------
You add the header ("Content-type:text/xml"); This came after.

Because there is no output in front of the header.
This error is due to the header (' content-type:text/html; '); There can be no output before the send header, no spaces, you need to put the header (...) The previous space is removed, or something else is removed, or the header is placed directly on top of the program to ensure that there is no output. Echo Print_r var_dump and other output forms
------Solution--------------------
Check the code. Perform one-step debugging and printing to troubleshoot where the problem occurs. Let me show you some solutions to your mistake online. Http://hi.baidu.com/xiaefun/blog/item/87fd5f82e96a3eaa0df4d2cb.html
------Solution--------------------
I've come across this problem, too. Problems generally occur in the following points
1. BOM Removal
2. Cannot appear other than XML characters
3. 4,?> After the end can not have a newline or even a space
------Solution--------------------
Menu Bar-format-in UTF-8 no BOM format encoding
------Solution--------------------
Well.. Just like you.
------Solution--------------------
discuss

This is not in the format of Notepad?

------Solution--------------------
There is no problem with the code above you. You must be mistaken about the code.
  • 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.