我的 server.php 文件代码如下。我收到一条错误消息“此页面包含以下错误:
第 2 行第 1 列的错误:文档末尾的额外内容下面是第一个错误之前的页面呈现。”
$server->register('restaurant');
// Define the method as a PHP function
function restaurant($id) {
$query = "SELECT * FROM `member_details` where Id=$id";
$result = mysql_query($query);
if(!$result )
{
die('Could not get data: ' . mysql_error());
}
$xml_output = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n";
$xml_output .= "<?xml-stylesheet type=\"text/xsl\" href=\"xsltDetails.xsl\"?>";
$xml_output .= "<dataset>\n";
for($x = 0 ; $x < mysql_num_rows($result) ; $x++){
$row = mysql_fetch_assoc($result);
$xml_output .= "<entry>\n";
$xml_output .= "<id>".$row['Id']."</id>\n";
$xml_output .= "<name>".$row['Name']."</name>\n";
$xml_output .= "<address>".$row['Address']."</address>\n";
$xml_output .= "<postcode>".$row['Postcode']."</postcode>\n";
$xml_output .= "<telephone>".$row['Telephone']."</telephone>\n";
$xml_output .= "<opentime>".$row['OpenTime']."</opentime>\n";
$xml_output .= "<restauranttype>".$row['ResType']."</restauranttype>\n";
$xml_output .= "<licence>".$row['Licence']."</licence>\n";
$xml_output .= "<keywords>".$row['Keywords']."</keywords>\n";
$xml_output .= "<cuisine>".$row['Cuisine']."</cuisine>\n";
$xml_output .= "</entry>\n";
}
$xml_output .= "</dataset>\n";
return $xml_output;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>