android cannot update table in mysql database

this is my .java

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(“http://*******.com/mobileproject/updateclass.php”);
try {
List nameValuePairsUpdate = new ArrayList(2);
nameValuePairsUpdate.add(new BasicNameValuePair(“code”, aCode[i]));
nameValuePairsUpdate.add(new BasicNameValuePair(“section”, aSection[i]));
nameValuePairsUpdate.add(new BasicNameValuePair(“registered”, Integer.toString(registered)));
nameValuePairsUpdate.add(new BasicNameValuePair(“empty”, Integer.toString(empty)));
nameValuePairsUpdate.add(new BasicNameValuePair(“status”, status));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

HttpResponse response = httpclient.execute(httppost);

} catch (ClientProtocolException e) {
} catch (IOException e) {
}

and this is my .php

mysql_connect(“localhost”,”******”,”********”);
mysql_select_db(“*******”);
$registered = $_POST['registered'];
$empty = $_POST['empty'];
$status = $_POST['status'];
$code = $_POST['code'];
$section = $_POST['section'];
mysql_query(“UPDATE Class SET registered = ‘$registered’ , empty = ‘$empty’ , status = ‘$status’ WHERE code = ‘$code’ AND section = ‘$section’”);

my problem is when i click the button (code in .java), the registered, empty and status columns (initial they contain values and then) become empty(no value)..what i missing here?


Try to echo/log the string, that you put into mysql_query like:

$sql = “UPDATE Class SET registered = ‘$registered’ , empty = ‘$empty’ , status = ‘$status’ WHERE code = ‘$code’ AND section = ‘$section’”;
echo $sql; // or yourowndebuglogfunction($sql);
mysql_query($sql);

And then try to run it directly in mysql.

链接地址: http://www.djcxy.com/p/29590.html

上一篇: 我应该在JSON中转换哪个集合并再次解析?

下一篇: android无法更新mysql数据库中的表