我们正在尝试使用ajax和php在MySQL数据库和Google API之间进行接口(在第3行“phpsqlajax_dbinfo.php”中定义了数据库信息)。我们想用Google API的lat / long创建一个标记,但是我们在“add(Child)”上遇到致命错误 实际错误消息:“在非对象”
上调用成员函数addChild()我们如何让db注册并存储信息?
<?php
require_once("phpsqlajax_dbinfo.php");
$xml = ("mapPointInfo.xml") ;
$newLatLng = $_POST['latlng']; //new markers LatLng
$newLatLng = substr($newLatLng, 1, -1); //removes first and last characters of
newLatLng which are ( and )
list($newLat, $newLng) = explode(",", $newLatLng);
//$newLng = substr($newLng, 1, 0);
$locName = $_POST['geoNameMarker']; //geocoded or simple incremented site name
$markerComment = $_POST['createMarker']; //comment entered by user
$userName = $_POST['user']; //acquire username from session
$voteValue = "likes"; //acquire vote value if any
date_default_timezone_set('America/New_York');
$timeStamp = date("m/d/Y G:i"); //get timestamp
year:month:date:hour:minutes:seconds (example: 11:6:31:14:31:42)
if($markerComment == null || $markerComment == '' || $markerComment == ' '){
$markerComment = ' ';
}
$markerComment = htmlentities($markerComment, ENT_QUOTES);
$locName = htmlentities($locName, ENT_QUOTES);
$marker = $xml->addChild('marker');
$marker->addAttribute('lat', $newLat);
$marker->addAttribute('lng', $newLng);
$marker->addAttribute('name', $locName);
$marker->addAttribute('type', 'user-sug');
$comment = $marker->addChild('comment', $markerComment); //add information to
latest/last marker
$comment->addAttribute('user', $userName);
$comment->addAttribute('vote', 'likes');
$comment->addAttribute('time', $timeStamp);
header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
header ('http://www.wmuhotspotmap.org/');
exit();
?>
答案 0 :(得分:0)
致命错误?您收到 致命错误。它以前如何?我猜它与$xml
是一个字符串这一事实有关,但你出于某种原因正在做$xml->addChild()
,好像它是一个带有函数的对象。