Guest User

Untitled

a guest
Aug 10th, 2018
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2. $username="100064_na55703";
  3. $password="Xboxhalo!2";
  4. $database="100064_parkering";
  5. $host = "parkering-100064.mysql.binero.se";
  6.  
  7. function parseToXML($htmlStr)
  8. {
  9. $xmlStr=str_replace('<','<',$htmlStr);
  10. $xmlStr=str_replace('>','>',$xmlStr);
  11. $xmlStr=str_replace('"','"',$xmlStr);
  12. $xmlStr=str_replace("'",'&#39;',$xmlStr);
  13. $xmlStr=str_replace("&",'&',$xmlStr);
  14. return $xmlStr;
  15. }
  16.  
  17. // Opens a connection to a MySQL server
  18. $connection=mysql_connect ($host, $username, $password);
  19. if (!$connection) {
  20. die('Not connected : ' . mysql_error());
  21. }
  22.  
  23. // Set the active MySQL database
  24. $db_selected = mysql_select_db($database, $connection);
  25. if (!$db_selected) {
  26. die ('Can\'t use db : ' . mysql_error());
  27. }
  28.  
  29. // Select all the rows in the markers table
  30. $query = "SELECT * FROM markers WHERE 1";
  31. $result = mysql_query($query);
  32. if (!$result) {
  33. die('Invalid query: ' . mysql_error());
  34. }
  35.  
  36. header("Content-type: text/xml");
  37.  
  38. // Start XML file, echo parent node
  39. echo '<markers>';
  40.  
  41. // Iterate through the rows, printing XML nodes for each
  42. while ($row = @mysql_fetch_assoc($result)){
  43. // ADD TO XML DOCUMENT NODE
  44. echo '<marker ';
  45. echo 'name="' . parseToXML($row['name']) . '" ';
  46. echo 'address="' . parseToXML($row['address']) . '" ';
  47. echo 'lat="' . $row['lat'] . '" ';
  48. echo 'lng="' . $row['lng'] . '" ';
  49. echo 'type="' . $row['type'] . '" ';
  50. echo '/>';
  51. }
  52.  
  53. // End XML file
  54. echo '</markers>';
  55.  
  56. ?>
Add Comment
Please, Sign In to add comment