INSERT query works in SQL but doesn't work from android app

Shakib Karami :

I'm trying to send an INSERT query to my SQL DataBase but it doesn't work and no error is appearing but the query works if I send it from phpMyAdmin. here is my PHP code :

if ($_POST['func'] == 2) {
$dbca = taskdb();
$dbca->set_charset("utf8");
$mobileUser = $_POST['phone'];
$fullnameUser = $_POST['fullname'];
$usernameUser = $_POST['username'];
$sql = "INSERT INTO users (UserPhone, Username, UserFullname) VALUES (?,?,?)";
$result = $dbca->prepare($sql);
$result->bind_param("sss", $mobileUser,$fullnameUser,$usernameUser);
echo json_encode(array('profileUser' => 'DONE'));
}

and here is my java(client) code which is inside an AsyncT doInBacground:

HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("http://192.168.2.26/MyProject/fetchData.php");
  try {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("func", "2"));
    nameValuePairs.add(new BasicNameValuePair("phone", Login.user_phone));
    nameValuePairs.add(new BasicNameValuePair("fullname", fullname.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("username", username.getText().toString()));
    Log.e("mainToPost", "mainToPost" + nameValuePairs.toString());
    UrlEncodedFormEntity form;
    form = new UrlEncodedFormEntity(nameValuePairs,"UTF-8");
    httppost.setEntity(form);
    HttpResponse response = httpclient.execute(httppost);
    InputStream inputStream = response.getEntity().getContent();
    Signup.InputStreamToStringExample str = new Signup.InputStreamToStringExample();
    responseSignup = str.getStringFromInputStream(inputStream);
    Log.e("response", "response -----" + responseSignup);
    jsonresponse = new JSONObject(responseSignup);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;

I'm getting "DONE" as the response in client but no row would be inserted into my DataBase. any help will be much appreciated.

Oshada :

add

$result->execute();

after

$result->bind_param("sss",  $mobileUser,$fullnameUser,$usernameUser);

in php file

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=103430&siteId=1