Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP和XML未在<;中呈现错误;?_Xml_Php - Fatal编程技术网

PHP和XML未在<;中呈现错误;?

PHP和XML未在<;中呈现错误;?,xml,php,Xml,Php,我最近在一台新服务器上设置了apache和php,但下面显示的错误是,我在旧服务器上呈现xml的php代码没有在新服务器上呈现。请有人帮助我: XML Parsing Error: XML or text declaration not at start of entity Location: `http://192.168.1.200/file.php` Line Number 4, Column 1:<?xml version = "1.0" ?><rows><

我最近在一台新服务器上设置了apache和php,但下面显示的错误是,我在旧服务器上呈现xml的php代码没有在新服务器上呈现。请有人帮助我:

XML Parsing Error: XML or text declaration not at start of entity
Location: `http://192.168.1.200/file.php`
Line Number 4, Column 1:<?xml version = "1.0" ?><rows><row id = '85'><cell>  </cell><cell> 85 </cell><cell image='folder.gif'> 55 </cell><cell> 61 </cell><cell> 2013-07-27 14:29:15 </cell><cell> ndegwa22@googlemail.com </cell><cell> salland@nts.nl </cell>
^
XML解析错误:XML或文本声明不在实体的开头
地点:`http://192.168.1.200/file.php`
第4行第1列:85 55 61 2013-07-27 14:29:15ndegwa22@googlemail.com  salland@nts.nl 
^
我的代码

<?php     
            require("config.php");
            header("Content-type:text/xml");
            echo "<?xml version = \"1.0\" ?>";
            echo "<rows>";

            $qry = "SELECT * FROM tickets WHERE parent_id = 0 ORDER BY message_id DESC";
            $res = mysql_query($qry) or die(mysql_error().$qry);

            while ($row = mysql_fetch_array($res))
            {
                echo "<row id = '{$row["id"]}'>";
                    echo "<cell> {$row["id"]} </cell>";
                    echo "<cell image='folder.gif'> {$row["ticket_id"]} </cell>";
                    echo "<cell> {$row["message_id"]} </cell>";
                    echo "<cell> {$row["date_time"]} </cell>";
                    echo "<cell> {$row["from_email"]} </cell>";
                    echo "<cell> {$row["to_email"]} </cell>";
                    echo "<cell> ".xmlEscape($row["subject"])." </cell>";  

                    echo "<cell><![CDATA[";

                        $ar = explode(";",$row["attachment"]);
                        foreach($ar as $key=>$value)
                        {
                            echo "<a target='_blank' href='Mail/attachments/{$value}'>{$value} </a>  &nbsp;";
                        }

                    echo "]]></cell>";
                    echo "<cell> {$row["eid"]}</cell>";
                    echo "<cell> {$row["email_status"]}</cell>";
                    echo "<cell> {$row["ticket_status"]}</cell>";
                    echo "<cell> {$row["entry_datetime"]}</cell>";

                    getChildMailXml($row["id"]);

                echo "</row>";
            }

            echo "</rows>";

?>
$value)
{
回声“;
}
回声“]]>”;
回显“{$row[“eid”]}”;
回显“{$row[“email_status”]}”;
回显“{$row[“票证状态”]}”;
回显“{$row[“entry_datetime”]}”;
getChildMailXml($row[“id”]);
回声“;
}
回声“;
?>

根据错误消息:

XML分析错误:XML或文本声明不在实体的开头 地点:

Line Number 4, Column 1: <?xml version = "1.0" ?><rows><row id = '85'><cell>  </cell><cell> 85 </cell><cell image='folder.gif'> 55 </cell><cell> 61 </cell><cell> 2013-07-27 14:29:15 </cell><cell> ndegwa22@googlemail.com </cell><cell> salland@nts.nl </cell>
                         ^
第4行第1列:85 55 61 2013-07-27 14:29:15ndegwa22@googlemail.com  salland@nts.nl 
^
您正在第四行输出XML声明(
)。如果输出XML声明,则必须在第一行输出它,即第1行(-而不是第4行(!)

修复脚本的输出,将其输出到第一行和第一列,这样就可以了

从您显示的代码中,在引入其他行的位置不可见,但您可以放心,无论给出错误消息的是什么,都不会说谎。因此,请放心,这实际上是第四行,而不是第一行,您需要修复它

如果您不了解其他行的引入位置和原因,请了解PHP如何向客户端输出数据。由于输入和输出是编程中的一个基本领域,我建议您从介绍开始学习,然后学习PHP手册的所有前几章:

如果您想在“只读”旁边添加一些交互式学习,codecademy上提供了PHP曲目:


标题(“内容类型:text/xml”)之前不应有任何空格、行或打印输出;回声“放置要求(“config.php”);在这些行之后归档

<?php
    header("Content-type:text/xml");
    echo "<?xml version = \"1.0\" ?>";
    require("config.php");
    echo "<rows>";
    echo "<row id='1'><cell>1</cell></row>";
    echo "</rows>";
?>


config.php文件中不应该有任何输出
file

尝试注释该行标题(“内容类型:text/xml”);删除
前面的所有行和空格,您的编程问题是什么?错误消息的哪一部分对您来说很难理解?你的概念是什么?这里发生了什么并触发了错误消息?看起来你在
thnx user2314588之前有一些输出。帮助我删除了很多空白,然后删除了?>在我的config.php中,它导致了我所有的问题sthnx hakre。记住我说过我写的代码在我的旧服务器上工作。刚刚配置了一个新的oneto使用dhtmlx…我将回到一个php thnx for URLWell的初学者课程,这只是一个配置问题。您还可以比较两个系统上phpinfo()的输出。检查与输出相关的设置。这个主题相当大,仅从您的代码就很难说了,所以只需要解决一些问题。