Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Values not being stored into MySQL database through php
    text
    copied!<p>I am sending some values through <code>HTTP Post</code> to my server from my Android emulator but the values are not being stored. My logcat is showing <code>response code 200</code> and displaying the codes of the <code>php</code> script as a http response. My database is fine as i am able to insert data in it. Any idea what might be the matter?</p> <p>main.java</p> <pre><code>public void sendRegistrationIdToServer(String deviceId, String registrationId) { System.out.println(registrationId); System.out.println(deviceId); HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://10.21.78.11/storePost.php?"); try { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1); // Get the deviceID nameValuePairs.add(new BasicNameValuePair("devid", deviceId)); nameValuePairs.add(new BasicNameValuePair("regid", registrationId)); //HttpProtocolParams.setUseExpectContinue(client.getParams(), false); post.addHeader("Content-Type", "application/x-www-form-urlencoded"); post.setEntity(new UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8)); // Execute HTTP Post Request HttpResponse response = client.execute(post); int status = response.getStatusLine().getStatusCode(); System.out.println("HTTP Status = "+status); BufferedReader rd = new BufferedReader(new InputStreamReader( response.getEntity().getContent())); String line = ""; while ((line = rd.readLine()) != null) { Log.e("HttpResponse", line); } } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>storePost.php</p> <pre><code>&lt;?php mysql_connect("localhost", "root", "") or die (mysql_error()); mysql_select_db("DeviceID"); $regid = mysql_real_escape_string($_POST["regid"]); $devid = mysql_real_escape_string($_POST["devid"]); mysql_query("INSERT INTO Android(regID, devID) VALUES ('$regid', '$devid')") or die(mysql_error()); mysql_close(); ?&gt; </code></pre>
 

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