I've been confuse for a long time to think what's wrong with my code.. MySQL keep writing and save it into the table with the same value when I try to INSERT a new value for specific column.
Here is my Table structure (reservation table):
reservation
-----------------
id_reservation int(3)
no_seat1 varchar(4)
no_seat2 varchar(4)
no_account int(13)
and here is my reservation.java code :
reservation = (Button) findViewById(R.id.bt_reservation);
reservation.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("no_seat1", no_seat1.getText().toString()));
postParameters.add(new BasicNameValuePair("no_seat2", no_seat2.getText().toString()));
postParameters.add(new BasicNameValuePair("no_account", no_account.getText().toString()));
String response = null;
try {
response = CustomHttpClient.executeHttpPost("http://10.0.2.2/cinemainfo/reservation.php", postParameters);
String res = response.toString();
res = res.trim();
res = res.replaceAll("\\s+","");
no_seat1.setText("");
no_seat2.setText("");
no_account.setText("");
Toast.makeText(getApplicationContext(), "Success!", Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
}
}
}
});
and here is my php code (reservation.php) :
$no_seat1 = $_POST['no_seat1'];
$no_seat2 = $_POST['no_seat2'];
$no_account = $_POST['no_account'];
$db_con = mysql_connect($db_host,$db_uid,$db_pass) or die('could not connect');
mysql_select_db($db_name);
$query = "INSERT INTO reservation VALUES ('','$no_seat1', '$no_seat2', '$no_account')";
$result = mysql_query($query) or die("FAILED save data!");
When I run in emulator..it's fine, but the data that saved in my reservation table seems wrong.. For the first insert, the data for no_account is 2147483647
and I've never input that number..
so i tried the second insert and it still the same...the data that saved in no_account column is 2147483647
.. and i don't have any idea what's wrong with my code...
I really appreciate any help that you give to me..thank you :)