【发布时间】:2014-11-11 04:23:05
【问题描述】:
我正在为 web 服务开发一个带有 php 的 android 应用程序。在我的应用程序中,我在 php 文件中插入、更新、删除和搜索查询并保存到 www root,然后我将 php 文件调用到 android 应用程序中。搜索功能运行良好,但删除功能不起作用。我已经附上了php文件,android代码和错误。谁能帮帮我???
**filename** (deletedetail.php)
<?php
include "config.php";
$id = $_POST['id'];
$sql1="delete from detail where id ='$id'";
$result=mysql_query($sql1);
if($result)
{
echo"OK";
}
else
{
echo "Error";
}
?>
**android CODE**
public String deleteDetail(int id) {
try {
httpclient = new DefaultHttpClient();
httppost = new HttpPost(
"http://10.0.2.2/dreamhotel/deletedetail.php"); // change this to your URL.....
nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("id",Integer.toString(id)));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
response = httpclient.execute(httppost,responseHandler);
} catch (Exception e) {
System.out.println(e.getMessage());
}
return response;
}
Error in Android
at com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
【问题讨论】:
-
尝试注释掉 System.out.println 看看会发生什么,如果出现错误,请发布整个 logcat 消息。
-
请添加完整的 logcat,而不是
System.out.println(e.getMessage());使用Log.e(e.toString);
标签: php android web-services