Note that there are some explanatory texts on larger screens.

plurals
  1. POsend data from android to php, may be data not reaching php end
    text
    copied!<p>i am trying to send some data from my android code to php file.</p> <p>and trying to fetch it back from php and display it in emulator my java code </p> <p>`</p> <pre><code> try{ URL url = null; String s="http://10.0.2.2/welcome.php"; url = new URL(s); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(s); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); Log.i("postData", response.getStatusLine().toString()); reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); stringBuilder = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { stringBuilder.append(line + "\n"); } } catch(Exception e) { Log.e("log_tag", "Error in http connection "+e.toString()); } finally { tx.setText(stringBuilder.toString()); // close the reader; this can throw an exception too, so // wrap it in another try/catch block. if (reader != null) { try { reader.close(); } catch (IOException ioe) { tx.setText((CharSequence) ioe); ioe.printStackTrace(); } } }`` </code></pre> <p>i am doing a stupidity by opening two different connections one for post and another for get, but problem is not with that. its with my http-post.execute method.</p> <p>my php code is <code>&lt;?php $pLat = $_POST['pLat']; $pLng = $_POST['pLng']; print_r("$_POST['pLat']"); print_r("$_POST['pLng']"); ?&gt;</code></p> <p>i think i've got problem in sending my data, coz if i echo sumthing on my php it shows on my emulator.</p> <p>please help </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload