第1行第2行出错:Web服务文档末尾的额外内容

时间:2017-12-13 22:40:16

标签: php mysql xml

有人能帮助我吗?当我运行它时,它在第1行的第2行显示错误:

  

文档末尾的额外内容。

我哪里出错了?我还是XML的新手。

observer_ptr

1 个答案:

答案 0 :(得分:0)

首先我建议您切换到MYSQLi,其次,ifelse语句丢失{},第三,下面的代码应该有用

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$user = $_GET['username'];
$pass = $_GET['password'];

$sql = "SELECT * FROM receptionist WHERE nama_receptionist = '$user'";
$result = mysqli_query($conn, $sql);

$password = $result['password'];

if ($pass == $password) {
    $response = "TRUE";
} else {
    $response = "FALSE"
}

header('Content-Type: text/xml');
echo "<?xml version='1.0'?>";
echo "<data>";
echo "<response>".$response."</response>";
echo "</data>";

mysqli_close($conn);
?>