php适用于wamp但不适用于000webhost

时间:2011-09-27 12:11:15

标签: php mysql

我有一个与WAMP服务器完美配合的php文件,但是当我尝试使用000webhost服务器时,我收到错误。 即第1栏第11行的错误:文件末尾的额外内容。 但是在错误下我得到了正确的查询答案,但不是我要求的格式。 有人可以帮忙吗? 这是代码:

<?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";
?>

2 个答案:

答案 0 :(得分:4)

000webhost默认添加分析代码。它可以对您的XML造成严重破坏。

你可以通过以下方式禁用它: http://members.000webhost.com/analytics.php

答案 1 :(得分:1)

首先:我怀疑000webhost是否给你root权限?

第二:您已经输出到屏幕后无法提交标题请求,请将标题行放在脚本的顶部。

相关问题