<?php
$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 "<?xml version=\"1.0\" encoding=\"utf-8\"? ><rcuSet>";
while($row = mysql_fetch_object($result)) {
echo "<no id=$row->no>";
echo "<ch>".$row->ch."</ch>";
echo "<f>".$row->f."</f>";
echo "</no>";
}
echo "</rcuSet>";
mysql_free_result($result);
mysql_close();
?>
刚开始可以输出字符串。但是查看源文件是XML格式的
加了行header("Content-type:text/xml");
就提示
-----------------------
无法显示 XML 页。
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。
--------------------------------------------------------------------------------XML 文档只能有一个顶层元素。处理资源 'http://localhost/getXML.php' 时出错。第 2 行,位置: 2 <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\ge...
------------------------
后来去掉了那个header("Content-type:text/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 "<?xml version=\"1.0\" encoding=\"utf-8\"? ><rcuSet>";
while($row = mysql_fetch_object($result)) {
echo "<no id=$row->no>";
echo "<ch>".$row->ch."</ch>";
echo "<f>".$row->f."</f>";
echo "</no>";
}
echo "</rcuSet>";
mysql_free_result($result);
mysql_close();
?>
刚开始可以输出字符串。但是查看源文件是XML格式的
加了行header("Content-type:text/xml");
就提示
-----------------------
无法显示 XML 页。
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。
--------------------------------------------------------------------------------XML 文档只能有一个顶层元素。处理资源 'http://localhost/getXML.php' 时出错。第 2 行,位置: 2 <b>Warning</b>: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\ge...
------------------------
后来去掉了那个header("Content-type:text/xml");
结果反而又没字符串了纠结的哥蛋疼哦
出这个错误是因为 header('Content-Type:text/html;');发送头之前不能有任何输出,空格也不行,你需要将header(...)之前的空格去掉,或者其他输出的东西去掉,或者把header 直接放到 程序最上面,保证没有什么输出。echo print_r var_dump 之类的输出形式
也没有什么别的输出
现在去掉那个header连最开始可以输出字符现在都不能了
555
1、去除BOM
2、不能出现除了XML外的其它字符
3、<?php前面不能有空格换行
4、?>结束之后也不能有换行甚至一个空格
怎么去BOM啊?
你用的是什么?
也没找到什么格式去BOM
就是一个UTF-8和UTF8+BOM
选择为UTF-8
但是还是不行
太弱了
不好玩
$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 "<?xml version=\"1.0\" encoding=\"utf-8\"?><rcuSet>";
while($row = mysql_fetch_object($result)) {
echo "<no id=\"".$row->no."\">";
echo "<ch>".$row->ch."</ch>";
echo "<f>".$row->f."</f>";
echo "</no>";
}
echo "</rcuSet>";
mysql_free_result($result);
mysql_close();
?>
PHP还是为UTF-8格式啊
这样好象又可以了。
崩溃了
PHP文件。MYSQL都是UTF-8的。
有二个问题我发现的
1。xml节点属性的no应该是双引号。这里改过来了。(\")
2。同一个PHP文件修改过后重新在浏览器中是没有反映。只能重新开一个浏览器窗口就是这么奇怪
靠
还是谢谢大家
PHP现在可以echo出XML了
但是在flash里ctrl+enter可以读到
单独运行生成的SWF文件读不到
为什么呢?
虽然生成的HTML可以读
但是我想SWF读
说明路径没有问题
应该是别的方面的问题