What am I doing wrong? Please help.

<?php 
  
    include '../../Controller/dbconn.php';
   
  function map()
{
  $myID = isset($_GET['cid']) ? $_GET['cid'] : false;
  if (!$myID) return '';

  $db = con();

  $sql = "SELECT restaurant_addr FROM restaurants WHERE restaurant_id = $myID";
  $stmt = $db->prepare($sql);
  $stmt->execute(array());
  $row = $stmt->fetch(PDO::FETCH_ASSOC);


  $geocode = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=".urlencode($row['restaurant_addr']));
   
  $lat_long = get_object_vars(json_decode($geocode));
  
  $lat_long = $lat_long['results'][0]->geometry->location->lat . "," . $lat_long['results'][0]->geometry->location->lng;

  // YOU NEED TO RETURN A VALUE HERE
  return $lat_long;
}
?>

Open in new window


 <script>
      var map;
      function initialize() {
        <br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Undefined offset: 0 in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Trying to get property of non-object in <b>C:\XAMPP\htdocs\KaonTaBai2\Model\Customer\restaurantinfo.php</b> on line <b>22</b><br />
        var myLatlng = new google.maps.LatLng(,);
        mapOptions = {
          zoom: 8,
          center: myLatlng
        };
        map = new google.maps.Map(document.getElementById('map'), mapOptions),
        marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
        });
      }
    </script>

Open in new window


I cant seem to pass the value of $lat_long to  var myLatlng = new google.maps.LatLng(,);
HermesStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mohan singhWeb developerCommented:
Undefined offset:  that means your array packet content have more than exist content
so check your array packet OR array content which you used
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mohan singhWeb developerCommented:
Undefined offset always occurred in array packets
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.