The script worked before I tried to add the $pointer var and the changes to the class. The error is on line 14 on the required class which is the public var $validFlag = "" ; line. What I'm trying to do is get the returned htmlmessage out of the $pointer array.
<?php
require_once 'phoogle1.php';
$map->setAPIKey("ABQIAAAA9Bwvj_jq9ffNHGrXz9VO7xQALgqu6nN6nANsf-df7YvO8yp53xT4EfomqwVsDae1dfRiXRIGSNS1cQ");
$addr = $_POST['q'];
$addrArray= unserialize($addr);
foreach($addrArray as $key => $value){
$map->addAddress($value);
$pointer = $map->addAddress($value);
if($map->validFlag=1){
$html = $map->validPoints[$pointer]['htmlMessage'];
}else {
$html = $map->invalidPoints[$pointer]['htmlMessage'];
}
$map->printGoogleJS();
}
?>
For the class all I did was add the "public" on the vars $invalidPoints & $validPoints and add the var $validFlag = ""; And then in the addAddress class I added the $this->validFlag = 1 and $this->validFlag = 0, lines.
---------class-----
class PhoogleMap{
public var $validFlag = "";
public var $validPoints = array();
public var $invalidPoints = array();
function addAddress($address,$htmlMessage=null){
if (!is_string($address)){
die("All Addresses must be passed as a string");
}
//$apiURL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=YahooDemo&location=";
$apiURL = "http://local.yahooapis.com/MapsService/V1/geocode?appid=DoO9dXzV34FMVcI3aXjfoWLtUj_UBTBW4ltfKXiEDnXMnbm2DJ__79_Aw.n3EA--&location=";
$addressData = file_get_contents($apiURL.urlencode($address));
$results = $this->xml2array($addressData);
if (empty($results['ResultSet']['Result']['Address'])){
$pointer = count($this->invalidPoints);
$this->invalidPoints[$pointer]['lat']= $results['ResultSet']['Result']['Latitude'];
$this->invalidPoints[$pointer]['long']= $results['ResultSet']['Result']['Longitude'];
$this->invalidPoints[$pointer]['passedAddress'] = $address;
$this->invalidPoints[$pointer]['htmlMessage'] = $htmlMessage;
$this->$validFlag=1;
}else{
$pointer = count($this->validPoints);
$this->validPoints[$pointer]['lat']= $results['ResultSet']['Result']['Latitude'];
$this->validPoints[$pointer]['long']= $results['ResultSet']['Result']['Longitude'];
$this->validPoints[$pointer]['passedAddress'] = $address;
$this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;
$this->$validFlag=0;
}
return $pointer;
}
}
I can't figure it out, thanks,