我正在努力在我的网站上显示标记。为此,我从sqlite3数据库获取数据。你能纠正我在哪里做错了吗?
我在wamp服务器中收到此错误: 第3行第1行的错误:xmlParsePI:无目标名称
这是我的代码:
maps.php:
<?php
require("phpsqlajax_dbinfo.php");
// Start XML file, create parent node
$doc = new DOMDocument("1.0");
$node = $doc->createElement ("marker");
$parnode = $doc->appendChild($node);
// Opens a connection to a MySQL server
class MyDB extends SQLite3
{
function __construct()
{
$this->open('mytrip.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
}
// Set the active MySQL database
// Select all the rows in the markers table
$query = "SELECT * FROM marker ";
$resultt = $db->query($query);
//if (!$result) {
// die('Invalid query: ' . mysql_error());
//}
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = $ret->fetchArray(SQLITE3_ASSOC)){
// Add to XML document node
$node = $doc->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->set_attribute("city_id", $row['id']);
$newnode->set_attribute("name", $row['name']);
// $newnode->set_attribute("address", $row['address']);
$newnode->set_attribute("latitude", $row['latitude']);
$newnode->set_attribute("longitude", $row['longitude']);
$newnode->set_attribute("type", $row['type']);
}
$xmlfile = $doc->dump_mem();
echo $xmlfile;
?>
phpsqlajax_dbinfo.php
<?
$username="username";
$password="password";
$database="username-databaseName"
?>