title: getJSON: NetworkError: 500 Internal Server Error
body: <p>I wrote a code that uses <strong>getJSON</strong> (see below). FireBug returns the following error message:</p>
  
  <pre><code>"NetworkError: 500 Internal Server Error - http://localhost:10088/test/myquery.php?query=SELECT%20tm%20FROM%20schedule%20WHERE%20val=%27BT009%27;"
  </code></pre>
  
  <p>I cannot figure out the reason of this error. Any help is highly appreciated.</p>
  
  <p>PS I tested this SQL query in MySQL Query Browser. It has returned 3 rows.</p>
  
  <p><strong>mainPage.php</strong></p>
  
  <pre><code>&lt;script&gt;
  function updateList(){
     var query = "SELECT tm FROM schedule WHERE val='BT009';";
  
     $.getJSON(
             'myquery.php?query='+query,
             function(data) 
             {
                 alert(data);
             }   
     );
  
  }
  
  $(document).ready(function() {
      updateList();
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>myquery.php</strong></p>
  
  <pre><code>&lt;?php
  include_once 'include/connect_db.php';
  
  if (isset($_GET['query'])) {
      $query = $_GET['query'];
  
      $condb = connectDB();
      $result=execute_query($query);
      closeDB($condb);
  
      $rows = array();
  
      if ($result &amp;&amp; mysql_num_rows($result)) {
          while($row = mysql_fetch_array($result)) {
              $rows[] = $row['tm'];
          }
      }   
  
      var_dump($rows);
  
      echo json_encode($rows);
  
  } else {
      echo json_encode("Failed");
  }
  ?&gt;
  </code></pre>