-3

我们正在尝试使用 ajax 和 php 在 MySQL 数据库和 Google API 之间进行接口(在第 3 行“phpsqlajax_dbinfo.php”定义了数据库信息)。我们想用谷歌 API 的 lat/long 创建一个标记,但我们在“add(Child)”上收到致命错误实际错误消息:“Call to a member function addChild() on a non-object”

我们如何让数据库注册和存储信息?

<?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();

?>
4

1 回答 1

0

致命错误?你得到一个致命的错误。它以前如何?我猜这与$xml字符串这一事实有关,但出于某种原因,您好像在做$xml->addChild()一个带有函数的对象。

于 2012-05-31T01:14:16.430 回答