PHP: undefined index error but variable has correct value when printed
I'm passing some values from an android app to a PHP script. I get an
undefined index error in my PHP script but the variables have the correct
values when I print them out from within the script. I want these errors
gone but I can't figure out why they are there in the first place. Here is
how they are passed to the PHP script.
//build url data to be sent to server
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username",username));
nameValuePairs.add(new BasicNameValuePair("password",password));
String result = "";
InputStream is = null;
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new
HttpPost("http://10.0.2.2/PasswordCheck.php");
httppost.setEntity(new
UrlEncodedFormEntity(nameValuePairs,"utf-8"));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("Connection", "Error in http connection "+e.toString());
}
No comments:
Post a Comment