Android无法更新mysql数据库中的表

Android无法更新mysql数据库中的表,android,mysql,database,Android,Mysql,Database,这是我的.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

这是我的.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) {
}
这是我的.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’”);

我的问题是,当我单击按钮(codein.java)时,registed、empty和status列(它们最初包含值,然后)变为空(无值)。我在这里遗漏了什么?

尝试回显/记录放入mysql\u查询的字符串,如:

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

然后尝试直接在mysql中运行它。

什么是
mysql\u查询
返回?如果返回false,
mysql\u error
告诉您什么?(顺便说一句,你文章中的引号有点奇怪——可能是剪切/粘贴问题)。它至少会向您显示是否提交了值。除此之外,表面上看起来一切都很好,只是缺少对SQL的绑定。我在php方面没有太多经验,但我认为查询中的引号不正确。也许再检查一下。这不是一个正确的字符串连接。