title: JSONException End of input at character 0 of
body: <p>Somehow my issue seems to be slightly different than the ones I could look up online!</p>
  
  <p>Basically I'm getting this error:</p>
  
  <pre><code>10-16 12:14:03.561: E/log_tag(1271): org.json.JSONException: End of input at character 0 of 
  </code></pre>
  
  <p>while trying to retrieve the following JSON result of a php script execution from an Android emulator on Eclipse: <code>[{"id":"3"}]</code></p>
  
  <p>From what I've read, my issue implies that the JSON result of my php-script (which works fine in my browser btw) is empty, but how so?</p>
  
  <p>Here's the code of my MainActivity class:</p>
  
  <pre><code>protected Void doInBackground(String... params) {
  
      //InputStream isr = null;
  
      // Connect to Database + Webserver
      try {
          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new HttpPost(
                  "http://10.0.2.2:8080/php/AndroidTest.php"); // My php script adress                                                                    
          httppost.setHeader("Content-Type", "application/json");
          httppost.setHeader("Accept", "JSON");                                                       
          HttpResponse response = httpclient.execute(httppost);
          HttpEntity entity = response.getEntity();
  
          int status = response.getStatusLine().getStatusCode();
  
          if(status== HttpStatus.SC_OK){
              jsonString = EntityUtils.toString(entity);
          }
  
          //isr = entity.getContent();
      } catch (Exception e) {
          // TODO: handle exception
          Log.e("log_tag", "Error Connecting to Database/Webserver: " + e.toString());
      }
  
      //Parse JSON data   
      try {
          String s = "";
          JSONObject jsonObject = new JSONObject(jsonString);
          JSONArray jArray = jsonObject.getJSONArray("id");
  
          for (int i = 0; i &lt; jArray.length(); i++) {
              //JSONArray jArray = jArray.getJSONArray("id");
              JSONObject json = jArray.getJSONObject(i);
              s = s + "ID: " + json.getString("id");
          }
          finalResult = s;
  
      } catch (Exception e) {
          // TODO: handle exception
          Log.e("log_tag", "Error Parsing JSON Data: " + e.toString());
      }
  
      return null;
  }
  
  protected void onPostExecute(String result) {
      //MainActivity.resultView.setText("Ergebnis: " + sResult);
      MainActivity.resultView.setText(finalResult);
  }
  </code></pre>
  
  <p>php-script:</p>
  
  <pre><code>&lt;?php
  
  $con = mysql_connect("localhost","root","mcf");
  if (!$con)
  {
    die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("mcf", $con);
  
  $result = mysql_query("SELECT id FROM Fragensatz1");
  
  while($row = mysql_fetch_assoc($result))
  {
      $output[]=$row;
  }
  
  print(json_encode($output));
  
  mysql_close($con);
  
  ?&gt;
  </code></pre>