You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '16'' at line 1
Code (PHP)
<?php
require("config.php");
$type_id =$_GET[type_id];
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;
}
$query = "SELECT * FROM local";
$query.= "WHERE type_id= '".$type_id."'";
$result = mysql_query($query,$connect);
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 'id ="' .parseToXML($row['id']) . '" ';
echo 'name ="' . $row['name'] . '" ';
echo 'address ="' . $row['address'] . '" ';
echo 'tel ="' . $row['tel'] . '" ';
echo 'detail ="' . $row['detail'] . '" ';
echo 'lat ="' . $row['lat'] . '" ';
echo 'lng ="' . $row['lng'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>