In my app I have an EditText where the user can add his personal info. When he is done writing, he clicks a button and the corresponding DB column is supposed to be updated, but is not.
Here is my php script :
<?php
$con = mysqli_connect('127.0.0.1','root','lokijuhy1');
mysqli_select_db($con,'twentythree');
$response = array();
if(isset($_POST['about_me']) && isset($_POST['name']) && isset($_POST['uid'])){
$about_me = $_POST['about_me'];
$name = $_POST['name'];
$uid = $_POST['uid'];
$query = "UPDATE profile SET about_me = $about_me WHERE unique_id = $uid";
$result = mysqli_query($con,$query);
if ($result){
$response["success"] = 1;
$response["message"] = "Success";
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "Table was not Updated";
echo json_encode($response);
}
}else {
$response["success"] = 0;
$response["message"] = "Something is missing!";
echo json_encode($response);
}
?>
And here is my Java code :
class updateProfile extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name",name));
params.add(new BasicNameValuePair("uid",uid));
params.add(new BasicNameValuePair("about_me", about_me));
JSONParser jsonParser = new JSONParser();
JSONObject json = jsonParser.makeHttpRequest(Config.URL_profileUpdate,
"POST", params);
try {
// Checking for SUCCESS TAG
int success = json.getInt("success");
String message = json.optString("message");
if (success == 1) {
System.out.println(message);
}
}catch (JSONException e) {
e.printStackTrace();
}
return null;
protected void onPostExecute(String file_url) {
}
Do you guys have any idea why this happens?
Note : I just noticed that I get a positive JSON response, but the response message is null.