Php android post请求(post[参数]没有值)

Php android post请求(post[参数]没有值),php,android,post,get,Php,Android,Post,Get,我无法从我的android应用程序发出post请求,一定有一些愚蠢的错误,我可以看到它 HttpPost httppost = new HttpPost("http://www.smth.net/some.php"); try { // Add your data List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new

我无法从我的android应用程序发出post请求,一定有一些愚蠢的错误,我可以看到它

HttpPost httppost = new HttpPost("http://www.smth.net/some.php");
try {
    // Add your data
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("pa", "555"));
    nameValuePairs.add(new BasicNameValuePair("pb", "550"));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
    HttpResponse response = httpclient.execute(httppost);
} catch (Exception e) { 
//no error thrown
}

试试这个让我知道会发生什么

HttpClient httpclient = new DefaultHttpClient();

    HttpPost httppost = new HttpPost("http://www.smth.net/some.php");
    httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");

    HttpPost httppost = new HttpPost("http://www.smth.net/some.php");

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("pa", "555"));
    nameValuePairs.add(new BasicNameValuePair("pb", "550"));

    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));

    // Execute HTTP Post Request

    HttpResponse response = httpclient.execute(httppost);

然后检查响应,您得到了什么..

为什么不看看异常是什么?这正是它们存在的目的…尝试使用var_转储值并在调试中获得其结果-检查使用HttpPost发布的内容。我打印日志时没有例外。vtag,不输入cathc;,所以它从不抛出errorLog.vvv,response.getStatusLine.getStatusCode;它返回200,但没有插入任何内容200表示,执行成功,只需检查服务器端的php脚本如何处理数据..OK 200请求已完成。是的,我知道,但$\u POST[pa]有一个值->空,我的请求中有问题我确定$\u POST[pa]为空,我检查了很多次,但我不明白为什么它是空的:
HttpClient httpclient = new DefaultHttpClient();

    HttpPost httppost = new HttpPost("http://www.smth.net/some.php");
    httppost.addHeader("Content-Type", "application/x-www-form-urlencoded");

    HttpPost httppost = new HttpPost("http://www.smth.net/some.php");

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("pa", "555"));
    nameValuePairs.add(new BasicNameValuePair("pb", "550"));

    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));

    // Execute HTTP Post Request

    HttpResponse response = httpclient.execute(httppost);