2014-07-18 55 views
0

我使用HttpPost插入ArrayList的值來用PHP MySQL,但我在我的MySQL的雙項我有提到我在底部安卓httppost的mysql沒有複式

HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost("http://"); 
ResponseHandler<String> responseHandler=new BasicResponseHandler(); 

try { 

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
    nameValuePairs.add(new BasicNameValuePair("a", a.getText().toString())); 
    nameValuePairs.add(new BasicNameValuePair("b", b.getText().toString())); 
    nameValuePairs.add(new BasicNameValuePair("c", c.getText().toString())); 
    nameValuePairs.add(new BasicNameValuePair("d", d.getText().toString())); 
    nameValuePairs.add(new BasicNameValuePair("e", e.getText().toString())); 
    nameValuePairs.add(new BasicNameValuePair("f", f)); 
    nameValuePairs.add(new BasicNameValuePair("g", g)); 

    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

    HttpResponse response = httpclient.execute(httppost); 

    String responseBody = httpclient.execute(httppost, responseHandler); 

    Toast.makeText(getApplicationContext(), responseBody, Toast.LENGTH_SHORT).show(); 

    Log.d("a", responseBody); 

回答

0

代碼你似乎是在執行httppost兩次。嘗試刪除您沒有使用response據我可以告訴行

HttpResponse response = httpclient.execute(httppost); 

+0

thnk you arth ..我的問題解決了... – user1514030

+0

@ user1514030沒問題,很高興幫助,請接受答案。 – Arth