[Android Studio] TobyDrane:
So I am creating this new app and it requires a database to store the users information. I can save to the database and fetch from the database, but it is not letting me update in the database. So the database looks like this...

user_id | position | name | mobile | address | email | company | cards_holding

They are all strings and the user_id is the user id that each user has when they register. I have edit texts in the app and a button that when the user presses it should update all the information in the database based on the user_id. So if user_id 4 is Bob and they have a position off "CEO", if they change that in the app to "Owner" it should change the position of CEO to Owner in user_id row.

Here is the PHP file I have created

<?php

$mysql_host = "private";
$mysql_database = "private";
$mysql_user = "private";
$mysql_password = "private";

$con = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);

$user_id = $_POST["user_id"];
$position = $_POST["position"];
$name = $_POST["name"];
$mobile = $_POST["mobile"];
$address = $_POST["address"];
$email = $_POST["email"];
$company = $_POST["company"];
$cards_holding = $_POST["cards_holding"];

$sql = "UPDATE cards SET position=$position, name=$name, mobile=$mobile, address=$address, email=$email, company=$company, cards_holding=$cards_holding WHERE user_id=$user_id";

mysqli_query($con, $sql);

mysqli_close($con);

?>

There is no errors in the php file. So here is the java code to updating the data

case R.id.bUpdate:
int ui = user.getUserID();

String position = editTextPosition.getText().toString();
String name = editTextName.getText().toString();
String mobile = editTextMobile.getText().toString();
String address = editTextAddress.getText().toString();
String email = editTextEmail.getText().toString();
String company = ediTextCompany.getText().toString();
String cardsHolding = "2";

Card card = new Card(ui, position, name, mobile, address, email, company, cardsHolding);
updateCard(ui, card);

break;

public void updateCard(int userId, Card card){
Server server = new Server(getContext());
server.updateCardDataInBackground(userId, card, new CardCallback() {
@Override
public void done(Card returnedCard) {
Log.i("APP", "UPDATED INFORMATION TO THE CARD DATABASE");
}
});
}

public void updateCardDataInBackground(int userid, Card card, CardCallback cardCallback) {
progressDialog.show();
new UpdateCardDataASyncTask(userid, card, cardCallback).execute();
}

public class UpdateCardDataASyncTask extends AsyncTask<Void, Void, Void> {

int userId;
Card card;
CardCallback cardCallback;

public UpdateCardDataASyncTask(int userId, Card card, CardCallback cardCallback){
this.userId = userId;
this.card = card;
this.cardCallback = cardCallback;
}

@Override
protected Void doInBackground(Void... params) {
ArrayList<NameValuePair> dataToSend = new ArrayList<>();
dataToSend.add(new BasicNameValuePair("user_id", Integer.toString(card.userId)));
dataToSend.add(new BasicNameValuePair("position", card.position));
dataToSend.add(new BasicNameValuePair("name", card.name));
dataToSend.add(new BasicNameValuePair("mobile", card.mobile));
dataToSend.add(new BasicNameValuePair("address", card.address));
dataToSend.add(new BasicNameValuePair("email", card.email));
dataToSend.add(new BasicNameValuePair("company", card.company));
dataToSend.add(new BasicNameValuePair("cards_holding", card.cardsHolding));

HttpParams httpRequestParams = getHttpRequestParams();
HttpClient client = new DefaultHttpClient(httpRequestParams);
HttpPost post = new HttpPost("webaddress" + "/UpdateCards.php");

try{
post.setEntity(new UrlEncodedFormEntity(dataToSend));
client.execute(post);
}catch (Exception e){
e.printStackTrace();
}

return null;
}

private HttpParams getHttpRequestParams(){
HttpParams httpRequestParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpRequestParams, ServerRequests.CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpRequestParams, ServerRequests.CONNECTION_TIMEOUT);
return httpRequestParams;
}

@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
progressDialog.dismiss();
cardCallback.done(null);
}
}

There is no errors in the code and the app doesnt crash, In the app it says it has updated to the database but it doesnt. Any help would be amazing thanks

Toby.