dqlxtv1452 2014-01-28 12:31
浏览 29

为什么MySQL在INSERT查询中继续写入相同的值

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 :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?