使用php xml sql在google地图上显示用户时出现的问题

使用php xml sql在google地图上显示用户时出现的问题,php,mysql,xml,google-maps,Php,Mysql,Xml,Google Maps,我正在使用代码获取半径范围内的用户,例如:25。当我试图在运行后检查xml文件的输出时,它只显示预定义的echo语句,而不显示sql数据。我不知道sql是否正在检索数据? 有谁知道这个问题,请回答 这是我的PHP代码: <?php require("phpsqlajax_dbinfo.php"); header("Content-type: text/xml"); function parseToXML($htmlStr) { $xmlStr=str_r

我正在使用代码获取半径范围内的用户,例如:25。当我试图在运行后检查xml文件的输出时,它只显示预定义的echo语句,而不显示sql数据。我不知道sql是否正在检索数据? 有谁知道这个问题,请回答

这是我的PHP代码:

<?php   
  require("phpsqlajax_dbinfo.php");
  header("Content-type: text/xml");

  function parseToXML($htmlStr) 
  { 
    $xmlStr=str_replace('<','&lt;',$htmlStr); 
    $xmlStr=str_replace('>','&gt;',$xmlStr); 
    $xmlStr=str_replace('"','&quot;',$xmlStr); 
    $xmlStr=str_replace("'",'&#39;',$xmlStr); 
    $xmlStr=str_replace("&",'&amp;',$xmlStr); 
    return $xmlStr; 
  } 

  // Get parameters from URL
  $center_lat = $_GET["lat"];
  $center_lng = $_GET["lng"]; 
  $radius = $_GET["radius"];

  // Opens a connection to a MySQL server
  $connection=mysql_connect ("localhost","$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 = sprintf("SELECT gender, username, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM register HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($center_lng),
  mysql_real_escape_string($center_lat),
  mysql_real_escape_string($radius));
  $result=mysql_query($query);
  if (!$result) {
    die('Invalid query: ' . mysql_error());
  }

  // Start XML file, echo parent node
  echo "<markers>\n";
  // 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['username']) . '" ';
    echo 'address="' . parseToXML($row['gender']) . '" ';
    echo 'lat="' . $row['lat'] . '" ';
    echo 'lng="' . $row['lng'] . '" ';
    echo 'distance="' . $row['distance'] . '" ';
    echo "/>\n";
  }

  // End XML file
  echo "</markers>\n";

?>

你有输出的例子吗?这是什么意思:它只是显示预定义的echo语句,而不是sql数据?@mkoistinen的意思是它根本不显示除我所回显的数据以外的任何数据。@mkoistinen它只是显示。。。。样本输出