Currently having trouble accessing some variables in the $_POST array of a server side script.
Context: I'm submitting some values to a mySQL server from an android device using PHP. When i "Create a new route" the php and java is working fine, for example:
Building a list of variables to post:
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("startLat", startLat));
params.add(new BasicNameValuePair("startLong", startLong));
params.add(new BasicNameValuePair("endLat", endLat));
params.add(new BasicNameValuePair("endLong", endLong));
params.add(new BasicNameValuePair("waypoints", waypoints.toString()));
params.add(new BasicNameValuePair("rating", rating));
params.add(new BasicNameValuePair("difficulty", difficulty));
params.add(new BasicNameValuePair("enjoyability", enjoyability));
params.add(new BasicNameValuePair("count", count));
params.add(new BasicNameValuePair("sum", sum));
params.add(new BasicNameValuePair("countDiff", countDiff));
params.add(new BasicNameValuePair("sumDiff", sumDiff));
params.add(new BasicNameValuePair("countEnjoy", countEnjoy));
params.add(new BasicNameValuePair("sumEnjoy", sumEnjoy));
I then call my method to post them:
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
//System.out.println(httpPost.getURI().toString());
//System.out.println(httpPost.getEntity().toString());
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
And this works fine and the values are available to the PHP script in the $_POST array. The problem i'm having is when I do the exact same process, using the following (Note in this case i'm "updating a route" and so there are a few less variables, this is reflected in the PHP script for updating a route.:
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("rating", Double.toString(currentRating)));
params.add(new BasicNameValuePair("difficulty", Double.toString(currentDiff)));
params.add(new BasicNameValuePair("enjoyability", Double.toString(currentEnjoy)));
params.add(new BasicNameValuePair("count", Double.toString(currentCount)));
params.add(new BasicNameValuePair("sum", Double.toString(currentSum)));
params.add(new BasicNameValuePair("countDiff", Double.toString(currentDiffCount)));
params.add(new BasicNameValuePair("sumDiff", Double.toString(currentDiffSum)));
params.add(new BasicNameValuePair("countEnjoy", Double.toString(currentEnjoyCount)));
params.add(new BasicNameValuePair("sumEnjoy", Double.toString(currentEnjoySum)));
JSONObject jsonEdit = jsonParser.makeHttpRequest(url_edit,
"POST" +
"", params);
The $_POST array is empty on the php script server side. I realise this may be a little vague but i hope you understand. i'm doing the exact same process of sending data for both methods, however the latter is empty.