abenzer/represent-map

geocode.php fails to set latitude and longitude

odebroqueville opened this issue · 1 comments

Using phpmyadmin, I manually entered 2 records in the table 'places', leaving the approved status, latitude, longitude, sector and sg_organisation_id empty. (On a side note, I'd like to mention that I had to create an 'events' table to get rid of an error generated by geocode.php. This is not stated in the setup.txt file.)
After entering 2 records manually, I ran the geocode.php script which produced the following messages:
"2 places geocoded
0 events geocoded"
Yet, visiting the database revealed that the lat and lng fields remained unchanged and set to 0 for both records!
It appears that the UPDATE to the database isn't taking place and I don't know why!
I'm using the following:
PHP Version 5.4.38
MySQL Version 5.5.46-cll

I found where the problem was coming from! Examining the $status var showed me I was submitting INVALID REQUESTS. This was being caused by my addresses containing French accents, such as "è" which was being incorrectly encoded as "%E8" for a reason I ignore! Because my database data is encoded in utf8 unicode ci, I resolved to replace the php function urlencode() by utf8_encode() to define the $request_url var.
geocode.php is now working properly and my database is being updated with the longitude and latitude for each record when calling geocode.php.