title: Uncaught Syntax Error. Unexpexcted end of input
body: <p>I have this javascript file that is calling a php file to return a JSON string. Chrome dev tools is throwing the error at line 10 in the javascript code. I know the error relates to a missing bracket but for the life of my and 3 other people who have looked at it the syntax is correct.</p>
  
  <pre><code>var request = new XMLHttpRequest();
  var listings = [];
  var json;
  var url = "getListing.php";
  request.open("GET", url, true);
  request.send();
  request.onreadystatechange = function(e)
  {
  if(request.readyState == 4){
      json = JSON.parse(request.responseText);
  
      for(var x = 0; x &lt; json.length; x++){
          var list = new listingInfo();
          list.category = json[x].category;
          list.date = json[x].dateListed;
          list.description = json[x].description;
          list.id = json[x].listingID;
          list.title = json[x].title;
          list.userID = json[x].userID;
          listings.push(list);
      }   
  }
  console.log(listings);
  }
  </code></pre>
  
  <p>here is the php file</p>
  
  <pre><code>&lt;?php
  session_start();
  $con = mysql_connect("localhost", "listAdmin", "hermes");
  if(!$con)
  {
      die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db("GregsList", $con)
      or die("Unable to select database:" . mysql_error());
  
  $result = mysql_query("SELECT * FROM Listings WHERE userID = '$_SESSION[userID]' ORDER BY dateListed DESC");
  
  #converts to json
  $rows = array();
  while($r = mysql_fetch_assoc($result)) 
  {
          $rows[] = $r;
  }
  
  #If you want to see if correct json is printing use ---&gt; print json_encode($rows);
  
  return json_encode($rows);
  ?&gt;
  </code></pre>