JSON response getting nothing
<p>I am using Android to login to a php-based web service hosted on 000webohst.com. This is my main file:</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ccse);

    user = (EditText)findViewById(R.id.userid_edit);
    password = (EditText) findViewById(R.id.passwd_edit);
    lbl = (TextView) findViewById(R.id.label);
}

public void login(View view)
{
    String userID = user.getText().toString();
    String passWord = password.getText().toString();

    parameters = new ArrayList&lt;NameValuePair&gt;();
    parameters.add(new BasicNameValuePair("tag", "login"));
    parameters.add(new BasicNameValuePair("userid", userID));
    parameters.add(new BasicNameValuePair("password", passWord));

    new loginTask().execute();

    Toast.makeText(this, "Login task executed!", Toast.LENGTH_LONG).show();
}

public class loginTask extends AsyncTask&lt;Void, Void, JSONObject&gt; {

    @Override
    protected JSONObject doInBackground(Void... params) {

        jsonParser = new JSONParser();

        return jsonParser.getJSONFromUrl(loginURL, parameters);
    }

     protected void onPostExecute(Void v) {

         try {

                if(json.getString("success") != null) {

                    JSONObject json_user = json.getJSONObject("user");

                    user.setText("");
                    password.setText("");

                    lbl.setText("Hello " + json_user.getString("name") );

                 }
                else {

                    lbl.setText("Error!");

                }

            } 
             catch (JSONException e) {

                e.printStackTrace();

            }
     } 

}
</code></pre>

<p>Then this is my JSON Parser file:</p>

<pre><code>public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

public JSONParser() {

}

public JSONObject getJSONFromUrl(String url, List&lt;NameValuePair&gt; params) {

    try {
        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();

    } 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 + "\r\n");
        }
        is.close();
        json = sb.toString();
        Log.e("JSON", json);
    } 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 this is the PHP file which I am trying to connect to:</p>

<pre><code>        &lt;?php

    header('Content-Type: application/json; charset=utf-8');
    require ('dbconnect.php');
    mysql_select_db("a7085864_ccse", $con) or die('Could not connect: ' . mysql_error());


    if(isset($_POST['tag']) &amp;&amp; $_POST['tag'] != "") {

    $response=array("success" =&gt; 0, "error" =&gt; 0);

    $userid = $_POST['userid'];
    $password = $_POST['password'];

    $sql="select StudentName from student where StudentID='$userid' and StudentPw='$password'";
    $result=mysql_query($sql);

    $count=mysql_num_rows($result);

            if($count==1) {
                while($row = mysql_fetch_array($result)) {

                    $response["success"]=1;
                    $response["user"]["name"]=$row["StudentName"];
                    echo json_encode($response);
                }

            }

            else {

                $response["error"]=1;
                $response["error_msg"] = "Error logging in.";
                echo json_encode($response);

            }

    }
    else {

    echo json_encode("Error getting data!");

    }


    exit();

    ?&gt;
</code></pre>

<p>However, on the Logcat, I don't seem to see my json returning anything by the Log.e("JSON",json) line. Previously, at least it would still return an analytic code error from the webserver. On top of that, is is followed by an error:</p>

<pre><code>05-06 01:06:33.511: E/JSON Parser(1835): Error parsing data org.json.JSONException: End of input at character 0 of 
</code></pre>

<p>Any idea on what is causing this? I can't figure out of the error comes from the PHP script or the Android program.</p>
