2011-09-06 190 views
0

我試圖從我的Android應用程序上傳數據到PHP,但是,我沒有收到server.i的數據嘗試回顯數據,任何人都可以幫助這個代碼,我我沒有得到任何錯誤無法發送數據從Android到PHP

nameValuePairs.add(new BasicNameValuePair("trip_id",x)); 
       nameValuePairs.add(new BasicNameValuePair("loc_lat",String.valueOf(location.getLatitude()))); 
       nameValuePairs.add(new BasicNameValuePair("loc_lon",String.valueOf(location.getLongitude()))); 
       HttpClient httpclient=new DefaultHttpClient(); 
       HttpPost httppost=new HttpPost("http://xx/x.php"); 
       httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
       HttpResponse response=httpclient.execute(httppost); 
       HttpEntity entity = response.getEntity(); 
       is = entity.getContent(); 
+0

你能夠在php腳本中獲取數據嗎? –

+0

沒有iam無法獲取php腳本中的數據 – RAHUL

回答

0

我有這樣的問題。我將你的代碼與我的代碼進行比較,但我記得問題在於服務器重定向我沒有發送POST請求。我必須輸入網站的IP並使用GET方法。 嘗試使用

HttpPost httppost=new HttpPost("x.x.x.x"); 

即使它不是一個解決方案(除非你的服務器有一個固定的IP),它可以幫助發現問題。

+0

不,它沒有解決我的問題 – RAHUL