由于以下原因,地理编码不成功 零结果 - PHP 个变量

Geocode was not successful for the following reason Zero result - PHP variables

我正在尝试显示调用地址 我的 sql 数据库,我无法显示地址 我一直收到此错误 "Geocode was not successful for the following reason Zero_Results"

我试图在一个变量 $address 中添加完整地址,而不是使用三个变量 $address , $county , $county 但仍然没有 正在工作,我无法弄清楚。

我想将地址显示为您在图片中看到的标记。

每当我将新地址添加到我的数据库中时,我都会将新标记添加到地图中。

任何帮助,

提前致谢。

这是我正在使用的代码:

$result = mysqli_query($con,"SELECT * FROM `test`") or die ("Error:      
 ".mysqli_error($con));
     while ($row = mysqli_fetch_array($result))
     {
            $address = $row['address'];
            $county = $row['County'];
            $country = $row['Country'];
     }
        mysqli_close($con); 

        <!DOCTYPE html>
         <html>
          <head>

       <script type="text/javascript"
           src="https://maps.googleapis.com/maps/api/js?                       
           key=mykey&sensor=false">

        </script>


         <script type="text/javascript">
          var geocoder;
          var map;
          function initialize() {
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(          
            53.41291,-8.243889999999965);
            var address = '<?php echo $address.', '.$country.', '.$county; ?                 
          >';

            var myOptions = {
              zoom: 6,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("map_canvas"),                  
             myOptions);
            geocoder.geocode( { 'address': address}, function(results,    
              status) {
              if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map, 
                    position: results[0].geometry.location
                });
              } else {
                alert("Geocode was not successful for the following reason:                    
               " + status);
              }
            });
          }
        </script>
        </head>
        <body onload="initialize()">
          <div id="map_canvas" style="width:500px; height:500px"></div>

        </body>
        </html>

我的问题解决了,我的解决方案是:

            <script type="text/javascript">
            var geocoder;
            var map;
            function initialize(address) {
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(   
              53.41291,-8.243889999999965);


            var myOptions = {
              zoom: 6,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("map_canvas"),            
            myOptions);
            <?php
            require('connection.php');

              $result = mysqli_query($con,"SELECT * FROM `test`") or die  
                ("Error: ".mysqli_error($con));
              $count = 0;


            ?>
            <?php  //Starts while loop so all addresses for the given 
                // information will be populated.
             $addresscounting=0;
               while($row = mysqli_fetch_assoc($result)) //instantiates 
                 // array
           { ?>   


             var address = "<?php echo $address ?>";


            geocoder.geocode( { 'address': address}, function(results,                 
             status) {
              if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map, 
                    position: results[0].geometry.location
                });
              } else {
                alert("Geocode was not successful for the following reason:             
             " + status);
              }
            });

         <?php
               $count++;

              } //ends while
          ?>
          }

          </script