Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌phpsqlajaxv3不工作。。。仅地图上未显示的标记_Javascript_Php_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 谷歌phpsqlajaxv3不工作。。。仅地图上未显示的标记

Javascript 谷歌phpsqlajaxv3不工作。。。仅地图上未显示的标记,javascript,php,google-maps,google-maps-api-3,Javascript,Php,Google Maps,Google Maps Api 3,对所有人,提前感谢你们的帮助。。 为了让这个google脚本正常工作,我完成了两个教程,但我无法从显示在地图上的数据库中获取地图图钉。XML是有效的,连接到db,只是引脚。。。代码如下 phpsqlajax_genxml2.php <?php header("Content-type: text/xml"); require("phpsqlajax_dbinfo.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('&

对所有人,提前感谢你们的帮助。。 为了让这个google脚本正常工作,我完成了两个教程,但我无法从显示在地图上的数据库中获取地图图钉。XML是有效的,连接到db,只是引脚。。。代码如下

phpsqlajax_genxml2.php

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

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; 
} 

// 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 = "SELECT * FROM markers WHERE 6";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}



// 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>';

?>

Html:


googlemapsajax+mySQL/PHP示例
//
phpsqlajax_dbinfo.php

<?
$username="$username";
$password="$password";
$database=" $database";
?>

谢谢你的帮助

以下是输出url: 如果您还需要什么,请告诉我

好的,将php改为回显xml而不是使用DOM,我得到了无效的xml。。。我想。。现在怎么办?或者我该如何启用DOM_xml b/c我完全被这一点吓坏了。。。再次感谢你,你会的


编辑:还添加了db php文件,并根据建议更新了其他文件

您的xml提要不起作用

opensourcefish.com/phpsqlajax\u genxml.php

给出:


致命错误:在第5行的/home1/mac4281/opensourcefish.com/phpsqlajax\u genxml.php中调用未定义的函数domxml\u new\u doc()


有关该问题的详细信息,请参阅问题。

您的xml提要不起作用

opensourcefish.com/phpsqlajax\u genxml.php

给出:


致命错误:在第5行的/home1/mac4281/opensourcefish.com/phpsqlajax\u genxml.php中调用未定义的函数domxml\u new\u doc()


有关该问题的详细信息,请参阅问题。

生成的xml无效。从标记标签中取出额外的支架:

 echo '<marker ';
解决方案2:

将xml数据放在xml文件中,而不是回显:

 $data= '<markers> ';

 while ($row = @mysql_fetch_assoc($result)){

 $data1 = '<marker ' . 'name="' . parseToXML($row['name']) . '" ' .
    'address="' . parseToXML($row['address']) . '" ' . 'lat="' . $row['lat'] . '" ' .
    'lng="' . $row['lng'] . '" ' . 'type="' . $row['type'] . '" ' . '/>';

 }

$data2 = '</markers>';

$xmlData = $data. $data1 . $data2;
file_put_contents("xmldata.xml", $xmlData);
另外,在html中添加以下内容,因为我们需要首先加载php文件:

<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>

所以所有文件现在看起来都是这样的:

生成的xml无效。从标记标签中取出额外的支架:

 echo '<marker ';
解决方案2:

将xml数据放在xml文件中,而不是回显:

 $data= '<markers> ';

 while ($row = @mysql_fetch_assoc($result)){

 $data1 = '<marker ' . 'name="' . parseToXML($row['name']) . '" ' .
    'address="' . parseToXML($row['address']) . '" ' . 'lat="' . $row['lat'] . '" ' .
    'lng="' . $row['lng'] . '" ' . 'type="' . $row['type'] . '" ' . '/>';

 }

$data2 = '</markers>';

$xmlData = $data. $data1 . $data2;
file_put_contents("xmldata.xml", $xmlData);
另外,在html中添加以下内容,因为我们需要首先加载php文件:

<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>

现在所有文件都是这样的:

所有人:非常感谢!我让它工作起来,结果是头球问题和一个愚蠢的错误。教训你们所有的“复制/粘贴游骑兵”,阅读你们的代码!!!
非常感谢你的帮助。你很早就说对了,这只是一个重复的标题。。我复制了,但忘了删除我复制的内容,它就从那里走下了山。再次感谢大家

所有人:非常感谢!我让它工作起来,结果是头球问题和一个愚蠢的错误。教训你们所有的“复制/粘贴游骑兵”,阅读你们的代码!!!
非常感谢你的帮助。你很早就说对了,这只是一个重复的标题。。我复制了,但忘了删除我复制的内容,它就从那里走下了山。再次感谢大家

您使用的是哪个版本的PHP?为了补充geocodezip的答案,domxml_new_doc()不再与PHP5捆绑在一起。查看更多详细信息!我将检查这些线程并进行一些更改。感谢使用版本5.2.17的帮助顺便说一句,现在看来我的xml显示为有效,但仍然只有一个没有PIN的映射。。。获取类型错误:xml为空。。。想法?检查更新的答案:)您使用的是哪个版本的PHP?为了补充geocodezip的答案,domxml_new_doc()不再与PHP5捆绑在一起。查看更多详细信息!我将检查这些线程并进行一些更改。感谢使用版本5.2.17的帮助顺便说一句,现在看来我的xml显示为有效,但仍然只有一个没有PIN的映射。。。获取类型错误:xml为空。。。想法?检查更新的答案:)没问题!但是,我建议不要这样做,只需编辑问题帖子。没问题!但是,我建议不要这样做,只需编辑问题帖子。
    $.get("phpsqlajax_genxml2.php");