为什么会出现以下错误:
此页面包含以下错误:第5行第1列的错误: 文档末尾的额外内容是以下内容的呈现 页面直到第一个错误。
这是我的代码:
<?php
@header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$dir = substr(trim($_REQUEST['Body']),0,3);
$msg = substr(trim($_REQUEST['Body']),3);
$phone = '0'.substr(trim($_REQUEST['From']),4);
if($dir == 'PRV'){
process_PreVoting($phone,$date,$msg);
}
function process_PreVoting($phone,$date,$msg){
//$mysqliobject = new dbobject();
global $mysqli;
$details = explode(";",$msg);
$officer_id = $details[1];
$userpassword = $details[2];
$lga = $details[3];
$ward = $details[4];
$poll_unit = $details[5];
$total_queue = $details[6];
if($total_queue=='')$total_queue=0;
$comments = $details[7];
$device_entry_date = $details[8];
//$resp = $mysqliobject->getcheckdetails($officer_id,$userpassword);
$sql = "SELECT * FROM master where phoneNo = '$phone' OR phonetwo = '$phone'";
$st = mysqli_query($mysqli, $sql);
$resp = mysqli_num_rows($st);
//$PtaW = mysqli_fetch_assoc($st);
if($resp > 0)
{
// check if record already exists
$sqls = mysqli_query($mysqli,"SELECT officer_code FROM pre_voting_info WHERE officer_code='$officer_id'");
$count = mysqli_num_rows($sqls);
if($count > 0)
{
mysqli_query($mysqli,"update pre_voting_info set total_queue='$total_queue', comments='$comments', modify_entry_date='$device_entry_date' WHERE officer_code='$officer_id'");
}
else
{
$resps = mysqli_query($mysqli,"insert into pre_voting_info(pu_name,ward_name,lga_name,total_queue,comments,entry_date,device_entry_date,officer_code) values ('$poll_unit','$ward','$lga','$total_queue','$comments','$device_entry_date','$device_entry_date','$officer_id')");
if($resps) {
return "PreVoting Post Successfully Added";
}
else {
return "Error, could not add PreVoting Details. ".$mysqli->error;
}
$my_file = "echolog.txt";
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
fwrite($handle, "PRE-VOTING SQL: ".$sql);
fclose($handle);
}
}else{
return "Invalid User Credentails: ".$mysqli->error;
$date = date('Y-m-d H:i');
mysqli_query($mysqli,"insert into logtable (phoneNo,title,logMsg,pu,logDate) values ('$phone','Accreditation','$info','$poll_unit','$date')");
}
}//Function close
当我在浏览器中预览源代码时,输出的唯一内容是:
<?xml version="1.0" encoding="UTF-8"?>
答案 0 :(得分:0)
必须有一些内容才能成为有效的xml文档,例如,这已经足够:
<?xml version="1.0" encoding="UTF-8"?>
<root></root>