I am trying to convert the Google Maps API example - Creating a Store Locator with PHP, MySQL & Google Maps - from MySQL to Oracle. I am almost done, but I am having a problem near the end where data from the database is added to XML. Can anyone help me?
[...]
//Program ok up to here, made connection, query database, etc, but then...
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each record
// Done like this with MySQL data and it works:
//while ($row = @mysql_fetch_assoc($result)){
// $node = $dom->createElement("marker");
// $newnode = $parnode->appendChild($node);
// $newnode->setAttribute("name", $row['id']);
// $newnode->setAttribute("address", $row['address']);
// $newnode->setAttribute("lat", $row['slat']);
// $newnode->setAttribute("lng", $row['slng']);
// $newnode->setAttribute("distance", $row['distance']);
//}
// How do I do this with Oracle? The following doesn't create a runtime error but it is returning 'documentElement is null
// or not an object', which means it ain't returning the data!
while ($row = oci_fetch_array ($statement, oci_assoc)) {
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name", $row['id']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['slat']);
$newnode->setAttribute("lng", $row['slng']);
$newnode->setAttribute("distance", $row['distance']);
}
// Break connection
oci_logoff($connection);
echo $dom->saveXML();
//End
Fetching data from Oracle into XML - Google Maps API
Moderator: General Moderators
-
hegelsHoliday
- Forum Newbie
- Posts: 2
- Joined: Wed Aug 27, 2008 4:49 pm
Re: Fetching data from Oracle into XML - Google Maps API
Are you sure there is data? did you try executing the SQL query in Oracle directly?
-
hegelsHoliday
- Forum Newbie
- Posts: 2
- Joined: Wed Aug 27, 2008 4:49 pm
Re: Fetching data from Oracle into XML - Google Maps API
Yes, there is data in the table and the query works. I tested the code up to the point where I show the code in my question.
Re: Fetching data from Oracle into XML - Google Maps API
How many times does your code iterate through the oracle resultset? (how many times it runs through the while loop)
Re: Fetching data from Oracle into XML - Google Maps API
By the way:
"Program ok up to here" could be a pretty big assumption. You should probably show us the rest of the code, at least the part that connects to the database. Where does $statement get declared?//Program ok up to here, made connection, query database, etc, but then...