Update 2: So I never have used the debug function in firebug, but I just looked at the script section and I get this, now I will try and figure this out.
Failed to load source for:
http://localhost/googleMap/phpsqlajax_genxml.php
Hiya,
I followed this tutorial below
http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#outputxml
I ran into trouble, near then end, I am hoping someone else here has
got this working and can help me discover my problem. Simply there are 4
steps to this tutorial
- Creating the Table
- Populating the Table
- Outputting XML with PHP
- Creating the Map
I successfully have completed all the steps, however the outputted xml
isn’t read by the google map I created. The files are all on the same
directory, and I didn’t change any of the file names from the
tutorial. The tutorial has a step to test if the php file called
phpsqlajax_genxml.php is outputting the xml and I successfully tested
it and it was.
The problem is that the map isn’t rendering the items I have in the
database, that should be converted to xml for the map to read.
Any help, or pointing me in the right direction would be much
appreciated.
UPDATE 1: I realize I don’t have any code to show here, there are just 3 files so I am not sure which will be of the best use. I Have a question that might help my issue though.
In the xml output part of the tutorial I am asked too
Call this PHP script from the browser
to make sure it’s producing valid XML.
If you suspect there’s a problem with
connecting to your database, you may
find it easier to debug if you remove
the line in the file that sets the
header to the text/xml content type,
as that usually causes your browser to
try to parse XML and may make it
difficult to see your debugging
messages.
This is the phpsqlajax_dbinfo.php file
<?php
$username="root";
$password="root";
$database="root-googleMap";
?>
This is the code for the generate xml, Is a xml document actually made after and can I open in, or is it temporary conversion. If so How do i do the step above to test, I dont really understand.
<?php
require("phpsqlajax_dbinfo.php");
// 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;
?>
I’m assuming (and hoping) you’re not using PHP 4 anymore and that this is the source of your problem, the functions relating to the DOM XML manipulation have been replaced with the DOMDocument class, which has different method names.
As such, I have refactored your code to be compatible with PHP 5: