title: Android : String method return Null
body: <p>I know that this Question is repeated but I can't find the answer in Internet.</p>
  
  <p><code>02-10 11:03:28.465  22410-22767/com.eztimetable.eztimetable I/System.out﹕ ERROR : null
  02-10 11:03:28.465  22410-22767/com.eztimetable.eztimetable I/System.out﹕ error
  02-10 11:03:28.595  22410-22410/com.eztimetable.eztimetable E/log_tag﹕ Error parsing data org.json.JSONException: Value error of type java.lang.String cannot be converted to JSONArray</code></p>
  
  <p>why am i getting error / null ?</p>
  
  <p>Below is the method that i use</p>
  
  <pre><code>//in LecturerScreen class
      public String getDataFromDB() {
      try {
          httpclient = new DefaultHttpClient();
          httppost= new HttpPost("http://192.168.1.9/my_folder_inside_htdocs/retrieve.php"); // make sure the url is correct.
          //add your data
          nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
          // Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar,
          nameValuePairs.add(new BasicNameValuePair("inputUser",inputUser.getText().toString().trim()));  // $Edittext_value = $_POST['Edittext_value'];
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();
          final String response = httpclient.execute(httppost,responseHandler);
  
          return response.trim();
  
      } catch (Exception e) {
          System.out.println("ERROR : " + e.getMessage());
          return "error";
      }
  }
  </code></pre>
  
  <p>and this is how i call the method</p>
  
  <pre><code>    //in LecturerTimetable class
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_lecturer_timetable);
  
      tl = (TableLayout) findViewById(R.id.maintable);
  
      final LecturerScreen getdb = new LecturerScreen();
  
      new Thread(new Runnable() {
          public void run() {
              data = getdb.getDataFromDB();
              System.out.println(data);
  
              runOnUiThread(new Runnable() {
  
                  @Override
                  public void run() {
                      ArrayList&lt;TimetableDisplay&gt; timetable = parseJSON(data);
                      addData(timetable);
                  }
              });
  
          }
      }).start();
  }
  </code></pre>
  
  <p>I dont know what where my wrong here. Could someone give me solution for this question.</p>
  
  <p>I am very new in developing Android program, so if anyone could guide, it would be an honor.
  Sorry for bad english.
  Thank you.</p>
  
  <p>--UPDATE--</p>
  
  <p>the php script</p>
  
  <pre><code>&lt;?php
  $hostname_localhost ="localhost";
  $database_localhost ="eztimetable";
  $username_localhost ="root";
  $password_localhost ="";
  $localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
  or
  trigger_error(mysql_error(),E_USER_ERROR);
  
  mysql_select_db($database_localhost, $localhost);
  
  $lecturerUser = $_POST['inputUser'];
  $query_search = "select lecturerCode from lectureraccount where lecturerId = '".$lecturerUser."'";
  $query_exec = mysql_query($query_search,$localhost) or die(mysql_error());
  while($row=mysql_fetch_assoc($query_exec))
          $json_output[]=$row;
  
  print(json_encode($json_output));
  
  mysql_close();   
  </code></pre>
  
  <p>?></p>