android无法更新mysql数据库中的表
这是我的.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’”);
我的问题是,当我点击按钮(在.java中的代码),注册的,空的和状态列(它们包含值的初始值然后)变为空值(没有值)。
尝试回显/记录字符串,并将其放入mysql_query中,如下所示:
$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中运行它。
链接地址: http://www.djcxy.com/p/29589.html上一篇: android cannot update table in mysql database
下一篇: Trying to send a string from an Android emulator to a webservice