I've got a database which I use in my android app (accounts).
I want the user to be able to change his/her password.
I'm using java, mySQL, PHP and JSON.
The username needs to be updated by their id, I just created the code to do this but I get an error...: "Error parsing data org.json.JSONException: Value < br>< table of type java.lang.String cannot be converted to JSONObject".
Here are some lines of code, I use:
PHP
$query = "UPDATE users SET username = :username WHERE id = :id";
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
I also need to check if the username is succesfully updated, but I'll do that later.
I just use:
$response["success"] = 1;
$response["message"] = "Username is succesfully changed!";
die(json_encode($response));
JAVA
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
id = sp.getInt("id", 1);
EditText newUsername = (EditText)findViewById(R.id.etNewUsername);
username = newUsername.getText().toString();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", Integer.toString(id)));
params.add(new BasicNameValuePair("username", username));
Log.d("request!", "starting");
JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);
Log.d("After updating username", json.toString());
But the Tag: "After updating username" doesn't appear after the error in the LogCat.
So I know the error is within the HttpRequest.
Maybe it's the id? Because it will be converted to a String and in the database the id is an integer?
Every help will be appreciated!
Thanks.