Browser not displaying file
Posted: Sun Oct 31, 2010 6:20 am
My PHP file keeps trying to save or open when i view it, even in firefox.
I'm trying to open it on a webserver and localhost but i still get the same pop-up window which asks me to either open it or save it.
The file is index.php:
I'm trying to open it on a webserver and localhost but i still get the same pop-up window which asks me to either open it or save it.
The file is index.php:
Code: Select all
<?php
require_once('connectvars.php');
$dbc = mysql_connect ($server, $username, $password);
if(!$dbc){
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db($database, $dbc);
if (!$db_selected){
die ('Cannot use db: ' . mysql_error());
}
$query = 'SELECT * FROM maps WHERE 1';
$result = mysql_query($query);
if (!$result){
die('Invalid query ' . mysql_error());
}
//creates an array of strings to hold the liens of the KML file
$kml = array('<?xml version="1.0" encoding="UTF-8"?>');
$kml[] = '<kml xmlns="http://earth.google.com/kml/2.1">';
$kml[] = ' <Document>';
$kml[] = ' <Icon>';
$kml[] = ' <href>http://maps.google.com/mapfiles/kml/pal2/icon18.png</href';
$kml[] = ' </Icon>';
$kml[] = ' <Icon>';
$kml[] = ' <href>http://maps.google.com/mapfiles/kml/pal2/icon18.png</href';
$kml[] = ' </Icon>';
//Adds note for each row
while ($row = @mysql_fetch_assoc($result)){
$kml[] = ' <Placemark>' . $row['id'] . '">';
$kml[] = ' <city> ' . htmlentities($row['city']) . '</city>';
$kml[] = ' <Point>';
$kml[] = ' <coordinates>' . $row['lng'] . ',' . $row['lat'] . '</coordinates>';
$kml[] = ' </Point>';
$kml[] = ' <Placemark>';
}
//End of XML file
$kml[]= '</Document>';
$kml[]= '</kml>';
$kmlOutput = join("\n", $kml);
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
?>