自從現在一週以來,我一直被這個錯誤困住,我用Google搜索並嘗試了所有可能的解決方案,包括Stackoverflow上的解決方案。這是我的代碼:檢查XML輸出是否有效
<?php
require("phpsqlsearch_dbinfo.php");
// Get parameters from URL
$center_lat = $_GET["lat"];
$center_lng = $_GET["lng"];
$radius = $_GET["radius"];
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Opens a connection to a mySQL server
$connection=mysqli_connect ("localhost", $username, $password);
if (!$connection) {
die("Not connected : " . mysqli_error());
}
// Set the active mySQL database
$db_selected = mysqli_select_db($connection, $database);
if (!$db_selected) {
die ("Can\'t use db : " . mysqli_error($connection));
}
// Search the rows in the markers table
$query = sprintf("SELECT id, name, address, lat, lng, (3959 * acos(cos(
radians('%s')) * cos(radians(lat)) * cos(radians(lng) -
radians('%s')) + sin(radians('%s')) * sin(radians(lat)))) AS
distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 ,
20",
mysqli_real_escape_string($connection, $center_lat),
mysqli_real_escape_string($connection, $center_lng),
mysqli_real_escape_string($connection, $center_lat),
mysqli_real_escape_string($connection, $radius));
$result = mysqli_query($connection, $query);
$result = mysqli_query($connection, $query);
if (!$result) {
die("Invalid query: " . mysqli_error($connection));
}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysqli_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("id", $row['id']);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("distance", $row['distance']);
}
echo $dom->saveXML();
?>
我的目標是輸出的XML瀏覽器,以確保它的工作,但我已經收到這些錯誤:
欲瞭解更多信息,請參閱:https://developers.google.com/maps/solutions/store-locator/clothing-store-locator 能有人幫助我?
您應該正確縮進您的代碼。它可以幫助每個人閱讀你的代碼,這對你也有好處。 – ryantxr
你可以粘貼你的XML輸出嗎?這是一個瀏覽器消息,而不是PHP error_log消息 – delboy1978uk
@ delboy1978uk我的XML輸出是附加的圖像 – sankareb