我有一个与WAMP服务器完美工作的php文件,但是当我尝试000webhost服务器时,我得到错误。例如,第11行第1列的错误:文档末尾的额外内容。然而,在错误下,我得到了查询的正确答案,但不是我要求的格式。有人能帮忙吗?下面是代码:
<?php
mysql_connect("localhost","root","");
mysql_select_db("ataxi");
$src= $_GET['src'];
$dest = $_GET['dest'];
$day= $_GET['day'];
$hour = $_GET['hour'];
$luggage= $_GET['luggage'];
$query="SELECT price, estime FROM prices WHERE src='$src' and dest='$dest' and day='$day' and hour='$hour' and luggage=$luggage;";
$result= mysql_query($query) or die("error:".$query);
header('Content-type: application/xml; charset="utf-8"',true);
echo "<table>'n";
while ($row= mysql_fetch_array($result)) {
echo "<record>'n";
echo "<price>".$row['price']."</price>'n";
echo "<estime>".$row['estime']."</estime>'n";
echo "</record>'n";
}
echo "</table>'n";
?>
000webhost默认附加分析代码。它可能会对XML造成严重破坏。
你可以通过以下命令禁用它:http://members.000webhost.com/analytics.php。
第一:我怀疑000webhost是否给你root访问权限?
第二:你不能在已经输出到屏幕后提交标题请求,把标题行放在脚本的顶部