CURL不在实时服务器上工作但在本地服务器上工作?

时间:2017-03-14 09:53:20

标签: php mysql json curl file-get-contents

<table class="table table-bordered">
<thead>
    <tr>
      <th>Date</th>
      <th>Client Name</th>
      <th>Location</th>
      <th>Distance Travelled</th>
      <th>Travel Track</th>                                       
    </tr>
</thead>
<?php 
    include 'db.php';
    $sql = 'SELECT travel_allwnce.date_of_travel, location.latitude, location.longitude, meeting_details.client_cname FROM travel_allwnce INNER JOIN meeting_details ON meeting_details.uid = travel_allwnce.uid INNER JOIN location ON location.uid = travel_allwnce.uid';         
    $travel = mysqli_query($conn,$sql);     
while ($row = mysqli_fetch_array($travel)) 
{?>         
<tbody>
    <tr class="active">
    <?php
        $latlong = $row[1].','.$row[2];
        $url = "http://maps.googleapis.com/maps/api/geocode/json?latlng={$latlong}&sensor=false";
        $ch = curl_init($url);          
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        curl_close($ch);
        $geocode = json_decode($output);
    ?>
    <td><?php echo $row[0];?></td>                  
    <td><?php print_r($geocode->results[0]->formatted_address);?></td>
    <td><?php echo $row[3];?></td>            
    <td><?php echo $row[3]?></td>
    <td><?php echo $row[3]?></td>             
    </tr>                               
</tbody>

  

相同的代码在localhost上正常工作。但在本地服务器上出错。   注意:未定义的偏移量:0英寸   /home/adnacbsllp/adtrack.adnacgroup.com/tables.php

     

注意:尝试获取非对象的属性   /home/adnacbsllp/adtrack.adnacgroup.com/tables.php

     

请帮助我。

0 个答案:

没有答案