title: Extract data from mysql and use them in javascript
body: <p>I'm trying to extract/get data from MySQL databse and use them in javascript. I found <a href="https://stackoverflow.com/questions/5568965/get-data-from-mysql-database-to-use-in-javascript">get data from mysql database to use in javascript</a> very useful but I'm not able to show anything (I've never used jQuery, so probably I'm missing something but I'm not able to figure out what yet)</p>
  
  <pre><code>&lt;?php
  error_reporting(0);
  require 'db/connect.php';
  require 'function/security.php';
  
  $records = array();
  
  if($result = $db-&gt;query("SELECT geoLat,geoLong FROM Stop")){
      if($result-&gt;num_rows){
          while ($row = $result-&gt;fetch_object()){
              $records[] = $row;
          }
          //$result-&gt;free();
      }
  }
  
  /*echo '&lt;pre&gt;', print_r($result),'&lt;/pre&gt;';
  echo '&lt;pre&gt;', print_r($records),'&lt;/pre&gt;';*/
  echo json_encode($records);
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;BrindisiBus&lt;/title&gt;
      &lt;style&gt;
      /* style settings for Google map */
      #map-canvas{
          width : 500px;  /* map width */
          height: 500px;  /* map height */
      }
      &lt;/style&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;!--- API GOOGLE MAPS V3 --&gt;
      &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
      &lt;script&gt;
  function initialize() {
      $.getJSON('paline.php', function(data) {
        $.each(data, function(fieldName, fieldValue) {
          $("#" + fieldName).val(fieldValue);
        });
      });
      /*
    var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
    var mapOptions = {
      zoom: 4,
      center: myLatlng
    }
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  
    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        title: 'Hello World!'
    });
  */
  }
  
  google.maps.event.addDomListener(window, 'load', initialize);
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id='map-canvas' &gt;&lt;/div&gt;&lt;br/&gt;
      &lt;p id="total"&gt;&lt;/p&gt;
      &lt;p id="fieldName"&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>With the query I get longitude and latitude, than I should save that values in js and create markers on the map.
  Is it possible to do everything in the same file?
  How could I check if getJSON is working at least and if it's giving errors?</p>