google geocode not working for addresses with special characters from database

后端 未结 2 1476
我寻月下人不归
我寻月下人不归 2021-01-27 03:07

I\'m having an issue with special characters for addresses from my database for google geocode, but not if I hardcode them.

Simple geocode code

$url = \"         


        
相关标签:
2条回答
  • 2021-01-27 03:42

    What if, you do the following:

    $query="SELECT * FROM mytable";
    $result=mysqli_query($GLOBALS["___mysqli_ston"], $query);
    while($row=mysqli_fetch_assoc($result)){
        $address = urlencode(mb_convert_encoding($row['address'], 'UTF-8'));
        // geocode code...
    }
    
    0 讨论(0)
  • 2021-01-27 03:50

    Try urlencode for database output data

    Like

     $address = urlencode($row['address'])
    

    Also remove this $address = str_replace(" ","+",$address); from current code.

    0 讨论(0)
提交回复
热议问题