Hi, I use phoogle in my sites and it works well, but today appear an error: Fatal error: Cannot use string offset as an array in /home/public_html/phoogle.php on line 132 Code (markup): In the line 132: if (empty($results['kml'][Response]['Placemark']['Point']['coordinates'])){ PHP: What's happen? Google changed something in the google maps api? Thankyou
Yesterday it works... but today no.. I tryied to put ['Response'] in all of [Response] and it doesn't works.... Thank you
I suddenly started getting this error too. (Fatal error: Cannot use string offset as an array in .... phoogle.php on line 132). I wonder if Google maps has changed its protocol. Here's a quick fix: Comment out the following lines of code in phoogle.php: $results = $this->xml2array(utf8_encode($addressData)); if (empty($results['kml'][Response]['Placemark']['Point']['coordinates'])){ $pointer = count($this->invalidPoints); $this->invalidPoints[$pointer]['lat']= $results['kml'][Response]['Placemark']['Point']['coordinates'][0]; $this->invalidPoints[$pointer]['long']= $results['kml'][Response]['Placemark']['Point']['coordinates'][1]; $this->invalidPoints[$pointer]['passedAddress'] = $address; $this->invalidPoints[$pointer]['htmlMessage'] = $htmlMessage; }else{ $pointer = count($this->validPoints); $this->validPoints[$pointer]['lat']= $results['kml'][Response]['Placemark']['Point']['coordinates']; $this->validPoints[$pointer]['long']= $results['kml'][Response]['Placemark']['Point']['coordinates']; $this->validPoints[$pointer]['passedAddress'] = $address; $this->validPoints[$pointer]['htmlMessage'] = $htmlMessage; } Replace with this: $xml = new SimpleXMLElement(utf8_encode($addressData)); $myCode = (string)$xml->Response->Status->code; $myCoordinates = (string)$xml->Response->Placemark->Point->coordinates; $myCoordinatesArray = explode(",", $myCoordinates); $pointer= '0'; $this->validPoints[$pointer]['long']= $myCoordinatesArray[0]; $this->validPoints[$pointer]['lat']= $myCoordinatesArray[1]; $this->validPoints[$pointer]['passedAddress'] = $address; $this->validPoints[$pointer]['htmlMessage'] = $htmlMessage; I'm not sure how robust this solution is, but for the moment it is working for me. Good luck, Anono123
Thank you very much. It works for me Edit: It works well in http://wwhatismyip.info. But in one of my sites... only shows one result http://deconcert.info/mapa-de-concerts, i have 8 places to show... :S
Add this line <?php if(!trim($data)) return; // strips all whitespace strings ?> before the first line of function characterData(...). It strips out the whitespace which is causing the errors. Had to fix it myself.
When I make those changes you suggested, the gmap only displays one marker for a location. I'm trying to pass at least 5 locations to the map hence 5 markers should display on the gmap.
I also get an error with an undefined offset at line 336. This error happens every other time I refresh the page. phoogle.php Line 332: function endElement($parser, $name) Line 333: { Line 334: $key=array_pop($this->keys); Line 335: if($this->node_flag==1){ Line 336: $this->arrays[$this->depth][$key]=$this->arrays[$this->depth+1]; Line 337: unset($this->arrays[$this->depth+1]); Line 338: } Line 339: $this->node_flag=1; Line 340: $this->depth--; Line 341: }
Ah ha! Got it! Just comment out the "$pointer='0' and add $pointer = count($this->validPoints); All the markers are displaying now! Nick Leung $xml = new SimpleXMLElement(utf8_encode($addressData)); $myCode = (string)$xml->Response->Status->code; $myCoordinates = (string)$xml->Response->Placemark->Point->coordinates; $myCoordinatesArray = explode(",", $myCoordinates); //$pointer= '0'; $pointer = count($this->validPoints); $this->validPoints[$pointer]['long']= $myCoordinatesArray[0]; $this->validPoints[$pointer]['lat']= $myCoordinatesArray[1]; $this->validPoints[$pointer]['passedAddress'] = $address; $this->validPoints[$pointer]['htmlMessage'] = $htmlMessage;
Hey! I just wanted to let both anono and ucdaz and everyone else who has contributed to this problem that I greatly appreciate your solutions. I had worked 22 hours a day for 2 weeks alone on a project for one of my most important clients to date on dynamic website and personalized content management system in which thousands of dollars were spent, and i used a customized version of this phoogle maps script. However this google maps script was an integral part of the main section on the website, and after all of my hard work, minutes after i scheduled a meeting with the client to present the final product, the script had randomly broken and i was mortified at the fatal error outputted by this now-broken code. The worst part was I spent two whole days testing and retesting my entire project and everything worked beautifully, and the one thing that was contingent upon an outside source was the one thing that broke, and i had no control over it. However your fix provided a quick and easy solution to this problem and i was able to get the website back online, and the rest of the presentation went smoothly. Granted i have worked in a few of my own personal failsafes to ensure stability and that something like this never happens again, but again i just wanted to thank all of you for your help on this issue!! I really appreciate it. Sorry for the life story! Cheers
I applied the above changes and now I receive an error: Notice: Trying to get property of non-object in C:\WebSite\htdocs\stripclubs\class_phoogle.php on line 134 Notice: Undefined offset: 1 in C:\WebSite\htdocs\stripclubs\class_phoogle.php on line 139 Line 134 is now: $myCoordinates = (string)$xml->Response->Placemark->Point->coordinates; Line 139 is now: $this->validPoints[$pointer]['lat']= $myCoordinatesArray[1]; I applied both bug fixes mentioned in this thread. Still nothing is working.
Nevermind got it working. My variables for city address etc. weren't functioning right. My error..not phoogles (after the bug fix).
The careless person who wrote this class forgot to include zoomLevel method support in the source code but did document it's use. Add this code to the class to support zoomLevel /** * @function zoomLevel * @param $zoomLevel:int * @returns nothing * @description Sets the zoom level of the map to be displayed (Range: 0-17; Default: 4.) */ function zoomLevel($zoom){ $this->zoomLevel = $zoom; } PHP:
Justin Johnson, the author of Phoogle, has posted an official fix at: http://www.webdevkungfu.com/fix-for-phoogle It's the same fix posted by Iiridayn above, trimming out the white space from $data at the start of function characterData. I recommend that you use this official fix, rather than the quick and dirty fix I posted above ("Quick fix for phoogle fatal error, line 132") on November 11. Nice work, Iiridayn. And thanks, Justin.