by aikidoguy » Wed Apr 04, 2012 7:48 pm
Im having a hard time with my eclipse IDE today... the data is not appearing in my database I think the error is in the .php file ... I'm fairly certain(about 85%) my code is sending the data but can someone confirm it for me please ... thank you
- Code: Select all
case R.id.boutofservice:
statuschange.setTextColor(Color.RED);
statuschange.setText("Out of Service");
statuscheck = "3";
SimpleDateFormat sdf111 = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date dd111 = new java.util.Date();
timeofchange.setTextColor(Color.RED);
timeofchange.setText("" + dd111);
putStatuschangeData(username, pass, group, statuscheck);
break;
private void putStatuschangeData(String gotBread, String teat,
String lockerroom, String StatusData) {
String db_url = "http://www.mywebsite.com/datatransfer.php";
//statuschange.setText("" + db_url);
InputStream is = null;
ArrayList<NameValuePair> request = new ArrayList<NameValuePair>();
request.add(new BasicNameValuePair("User", gotBread));
request.add(new BasicNameValuePair("Password1", teat));
request.add(new BasicNameValuePair("Group1", lockerroom));
request.add(new BasicNameValuePair("StatusChange1", statuscheck));
try {
HttpClient httpclient = new DefaultHttpClient();
Log.d("log_tag", "Got this far " + httpclient);
HttpPost httppost = new HttpPost(db_url);
httppost.setEntity(new UrlEncodedFormEntity(request));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
String s = convertStreamToString(is);
Log.d("log_tag", "Result: " + s);
timeofchange.setText("Data Sent" + s);
} catch (Exception e) {
e.printStackTrace();
Log.d("log_tag", "Error: " + e.toString());
timeofchange.setText("Data Not Sent");
}// catch
}// send