title: error converting result.java.lang.NullPointerException
body: <p>I just didnt know how to solve this error. and it also shows error "Error Parsing Data.org.json.JSONException:End of input at character 0 of" in the log cat. i didnt have the basic for android and all. but i really needed this. can anybody help me please?</p>
  
  <p>here is my JSONParser.java</p>
  
  <pre><code>public class JSONParser {
  static InputStream is = null;
  static JSONObject jObj = null;
  static String json = "";
  
  public JSONParser(){
  
  }
  
  public JSONObject getJSONFromUrl(final String url)
  {
      try
      {
          DefaultHttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url);
  
          HttpResponse httpResponse = httpClient.execute(httpPost);
          HttpEntity httpEntity = httpResponse.getEntity();
          is = httpEntity.getContent();
  
      }
      catch (UnsupportedEncodingException e)
      {
          e.printStackTrace();
      }
      catch (ClientProtocolException e)
      {
          e.printStackTrace();
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
  
      try
      {
          BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
          StringBuilder sb = new StringBuilder();
          String line = null;
          while((line=reader.readLine()) != null)
          {
              sb.append(line + "\n");
          }
          is.close();
          json = sb.toString();
      }
      catch(Exception e)
      {
          Log.e("Buffer Error", "Error Converting Result " + e.toString());
      }
      try
      {
          jObj = new JSONObject(json);
      }
      catch(JSONException e)
      {
          Log.e("JSON Parser", "Error Parsing Data " + e.toString());
      }
  
      return jObj;
  }
  
      public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params){
          try{
              if(method.equals("POST")){
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  HttpPost httpPost = new HttpPost(url);
                  httpPost.setEntity(new UrlEncodedFormEntity(params));
  
                  HttpResponse httpResponse = httpClient.execute(httpPost);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
  
              }else if(method.equals("GET")){
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  String paramString = URLEncodedUtils.format(params, "utf-8");
                  url += "?" +  paramString;
                  HttpGet httpGet = new HttpGet(url);
  
                  HttpResponse httpResponse = httpClient.execute(httpGet);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
              }
              }catch(UnsupportedEncodingException e){
                  e.printStackTrace();
              }catch(ClientProtocolException e){
                  e.printStackTrace();
              }catch(IOException e){
                  e.printStackTrace();
              }
              try{
                  BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
                  StringBuilder sb = new StringBuilder();
                  String line = null;
                  while ((line = reader.readLine()) != null) {
                      sb.append(line + "\n");
                  }
                  is.close();
                  json = sb.toString();
              }catch(Exception e){
                  Log.e("Buffer Error.", "Error Converting Result." + e.toString());
              }
  
              try{
                  jObj = new JSONObject(json);
              }catch(JSONException e){
                  Log.e("JSON Parser", "Error Parsing Data." + e.toString());
              }
  
              return jObj;
  
  }
  }
  </code></pre>
  
  <p>and here is my login.java</p>
  
  <pre><code>public class Login extends Activity implements OnClickListener{
  
  private EditText user, pass;
  private Button mSubmit;
  private TextView mRegister;
  
  private ProgressDialog pDialog;
  
  JSONParser jsonParser = new JSONParser();
  
  private static final String LOGIN_URL = "http://10.111.70.109/webservice/register.php";
  
  private static final String TAG_SUCCESS = "success";
  private static final String TAG_MESSAGE = "message";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
  
      user = (EditText)findViewById(R.id.username);
      pass = (EditText)findViewById(R.id.password);
  
      mSubmit = (Button)findViewById(R.id.btnLogin);
      mRegister = (TextView)findViewById(R.id.link_to_register);
  
      mSubmit.setOnClickListener(this);
      mRegister.setOnClickListener(this);
  }
  
  @Override
  public void onClick(View v){
      switch (v.getId()) {
      case R.id.btnLogin:
          new AttemptLogin().execute();
          break;
      case R.id.link_to_register:
          Intent i = new Intent(getApplicationContext(), SignUp.class);
          startActivity(i);
          break;
      default:
          break;
      }
  }
  
  class AttemptLogin extends AsyncTask&lt;String, String, String&gt;
  {
      boolean failure = false;
  
      @Override
      protected void onPreExecute(){
          super.onPreExecute();
          pDialog = new ProgressDialog(Login.this);
          pDialog.setMessage("Please Wait. Attempting Login..");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          pDialog.show();
      }
  
      @Override
      protected String doInBackground(String...args){
          int success;
          String username = user.getText().toString();
          String password = pass.getText().toString();
          try{
              List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
              params.add(new BasicNameValuePair("username", username));
              params.add(new BasicNameValuePair("password", password));
              Log.d("Request!", "Starting");
  
              JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params);
              Log.d("Login Attempt..", json.toString());
  
              success = json.getInt(TAG_SUCCESS);
              if(success==1){
                  Log.d("Login Successful!", json.toString());
                  Intent i = new Intent(Login.this, MainActivity.class);
                  finish();
                  startActivity(i);
                  return json.getString(TAG_MESSAGE);
              }else{
                  Log.d("Login Failure!", json.getString(TAG_MESSAGE));
                  return json.getString(TAG_MESSAGE);
              }
          }catch(JSONException e){
              e.printStackTrace();
          }
  
          return null;
      }
  }
  
  protected void onPostExecute(String file_url){
      pDialog.dismiss();
      if(file_url != null){
          Toast.makeText(Login.this, file_url, Toast.LENGTH_LONG).show();
      }
  }
  
  }
  </code></pre>
  
  <p>and here is my php scripts for login :</p>
  
  <pre><code>&lt;?php
  require("config.inc.php");
  
  if(!empty($_POST))
  {
      $query = "SELECT username, email, password FROM students WHERE username =:username";
      $query_params = array(':username'=&gt;$_POST['username']);
  
      try
      {
          $stmt = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($query_params);
      }
      catch(PDOException $ex)
      {
          $response["success"] = 0;
          $response["message"] = "Error. Please Try Again.";
          die(json_encode($response));
      }
      $validated_info = false;
  
      $row = $stmt-&gt;fetch();
      if($row)
      {
          if($_POST['password']===$row['password'])
          {
              $login_ok = true;
          }
      }
      if($login_ok)
      {
          $response["success"] = 1;
          $response["message"] = "Login Successful!";
          die(json_encode($response));
      }else{
          $response["success"] = 0;
          $response["message"] = "Sorry. Please Try Again.";
          die(json_encode($response));
      }
  }else{
  ?&gt;
  </code></pre>
  
  <p>can anybody help me? i would really appreciate it.</p>