次のスクリプトを使用しようとしています: https://developers.google.com/maps/articles/phpsqlajax
Google はこのスクリプトを呼び出します: phpsqlajax_genxml.php
php_domxml 拡張機能を確認し、wampserver を再起動しました。私はphp 5.2.9-2を実行しています。
phpsqlajax_dbinfo.php というスクリプトで、命令ごとに $username、$password、および $database を定義しました。
エラーを引き起こしています。これらの問題の原因を知っていますか?
警告: domnode::append_child() は、7 行目の E:\wamp\www\phpsqlajax_genxml.php で指定された、パラメーター 1 がオブジェクトであると想定しています。
注意: 未定義の定数 localhost の使用 - 10 行目の E:\wamp\www\phpsqlajax_genxml.php で「localhost」を想定
注意: 未定義の変数: 10 行目の E:\wamp\www\phpsqlajax_genxml.php のユーザー名
注意: 未定義の変数: 10 行目の E:\wamp\www\phpsqlajax_genxml.php のパスワード
警告: mysql_connect() [function.mysql-connect]: E:\wamp\www\phpsqlajax_genxml.php 行 10 のユーザー 'ODBC'@'localhost' (パスワードを使用: NO) のアクセスが拒否されました 接続されていません: アクセスが拒否されましたuser 'ODBC'@'localhost' (使用するパスワード: NO) `
// Start XML file, create parent node
$doc = domxml_new_doc("1.0");
$node = $doc->create_element("markers");
$parnode = $doc->append_child($node);
// Opens a connection to a mySQL server
$connection=mysql_connect ("localhost", $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysql_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 = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
$node = $doc->create_element("marker");
$newnode = $parnode->append_child($node);
$newnode->set_attribute("name", $row['name']);
$newnode->set_attribute("address", $row['address']);
$newnode->set_attribute("lat", $row['lat']);
$newnode->set_attribute("lng", $row['lng']);
$newnode->set_attribute("type", $row['type']);
}
$xmlfile = $doc->dump_mem();
echo $xmlfile;
?>
`