Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username="100064_na55703";
- $password="Xboxhalo!2";
- $database="100064_parkering";
- $host = "parkering-100064.mysql.binero.se";
- function parseToXML($htmlStr)
- {
- $xmlStr=str_replace('<','<',$htmlStr);
- $xmlStr=str_replace('>','>',$xmlStr);
- $xmlStr=str_replace('"','"',$xmlStr);
- $xmlStr=str_replace("'",''',$xmlStr);
- $xmlStr=str_replace("&",'&',$xmlStr);
- return $xmlStr;
- }
- // Opens a connection to a MySQL server
- $connection=mysql_connect ($host, $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");
- // Start XML file, echo parent node
- echo '<markers>';
- // Iterate through the rows, printing XML nodes for each
- while ($row = @mysql_fetch_assoc($result)){
- // ADD TO XML DOCUMENT NODE
- echo '<marker ';
- echo 'name="' . parseToXML($row['name']) . '" ';
- echo 'address="' . parseToXML($row['address']) . '" ';
- echo 'lat="' . $row['lat'] . '" ';
- echo 'lng="' . $row['lng'] . '" ';
- echo 'type="' . $row['type'] . '" ';
- echo '/>';
- }
- // End XML file
- echo '</markers>';
- ?>
Add Comment
Please, Sign In to add comment