I am working on an Android App that Collects certain information from a PHP MysQl Server, but I am facing a problem with JSON Parser, sometimes it works sometimes it does not work, it gives me these Errors:
E/JSON Parser﹕ Error parsing data org.json.JSONException: Value Failed of type java.lang.String cannot be converted to JSONObject
Caused by: java.lang.NullPointerException
And the Code thats producing the Errors:
try {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
params.add(new BasicNameValuePair("fname", fname));
params.add(new BasicNameValuePair("lname", lname));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("city", city));
params.add(new BasicNameValuePair("nrc", nrc));
params.add(new BasicNameValuePair("dob", dob));
params.add(new BasicNameValuePair("cell", cell));
Log.d("username", username);
Log.d("password", password);
Log.d("fname", fname);
Log.d("lname",lname );
Log.d("email",email );
Log.d("city",city );
Log.d("nrc",nrc );
Log.d("dob",dob );
Log.d("cell",cell );
Log.d("request!", "starting");
//Posting user data to script
JSONObject json = jsonParser.makeHttpRequest(
REGISTER_URL, "POST", params);
// full json response
Log.d("Registering attempt", json.toString());
// json success element
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Log.d("User Profile Created!", json.toString());
The NullException is being caused by the Line:
Log.d("Registering attempt", json.toString());
Aucun commentaire:
Enregistrer un commentaire