0

I am trying to fix a friends program....

It takes an excel spread sheet and geocodes the address and stores the long and lat in a database..

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/redmond/jquery-ui.css">
<link rel="stylesheet" href="ls.css">

 <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/polygonEdit.js"></script>
<script type="text/javascript" src="js/ajaxfileupload.js"></script>
<script type="text/javascript" src="js/poly.js"></script>
<script type="text/javascript" src="js/def.js"></script>
<script type="text/javascript" src="js/territory.js"></script>
<script type="text/javascript" src="js/jquery.ui.map.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.map.services.min.js"></script>

<script type="text/javascript">


</script>

It make a call to read the excel file and then geocode the address The excel upload function is written in PHP

$addr .= $objWorksheet->getCellByColumnAndRow($i, $row_num)->getValue() . ' ';
$a = get_geocode(urlencode(trim($addr)));

function get_geocode($addr) {
    // check to see if we have a geocode value
    $sql = sprintf("select latitude, longitude from geocodes where address =  '%s'", $addr);
    $rs = mysql_query($sql) or die (log_msg(mysql_error() . $sql));
    if (mysql_num_rows ( $rs) > 0) {
        //log_msg('found in db: ' . $addr);
        return(mysql_fetch_array($rs));
    } else {
        // we need to geocode.
        $a = geocode(urlencode($addr));
        // Save the results to speed up the next search.
        if ($a[0] > 0) {
            $sql = sprintf("insert into geocodes(address, latitude, longitude) values (%s, %s, %s)", dbquote($addr, 'text'), $a[0], $a[1] );
            //log_sql($sql);
            mysql_query($sql);
        }
        return $a;
    }
}

geocode returns :Geo error: 610,0,0,0

Help....

manlio
  • 18,345
  • 14
  • 76
  • 126
  • You are vulnerable to [SQL injection attacks](http://bobby-tables.com) and using a deprecated/obsolete db interface. – Marc B Mar 23 '14 at 01:20
  • possible duplicate of [Google Geocoding v2 API stopped working suddenly](http://stackoverflow.com/questions/15288244/google-geocoding-v2-api-stopped-working-suddenly) – Anonymous Mar 23 '14 at 01:22
  • Has this operated correctly before and is just now failing? Or is this a new project? Can you look at the raw data in the excel file. Normally when I see stuff like this it is caused by a bunk cell value somewhere or a consumption code problem. This may not seem helpful but it could help us help you. Also what is the version of excel? That might lend a clue and get you closer to a solution. – Frank Tudor Mar 23 '14 at 01:23
  • Another thing...Where are you calling the geocode request? That is javascript and I don't see it in your post. You know it might help to simplify your problem by separating concerns. When I look at this you are reading and (I assume) geocoding and then stuffing records in a DB all in one jump. You may need to read and loop through insert DB try/catch/throw and see if you have good data. Then check it that everything went ok, then geocoding loop and try/catch/throw so you can see when and where it fails. – Frank Tudor Mar 23 '14 at 01:35

0 Answers0