This is how I post the values with Volley:
@Override protected Map<String, String> getParams() { JSONObject jsonObjectMembers=new JSONObject(); for (int i=0; i<arr_added_userids.size(); i++) { try { jsonObjectMembers.put("params_"+i,arr_added_userids.get(i)); } catch (JSONException e) { e.printStackTrace(); } } Map<String, String> params = new HashMap<String, String>(); params.put("host", session_userid); params.put("params",jsonObjectMembers.toString()); return params; } This is what I tried:
foreach($_POST['params'] as $key => $value) { try { $stmt = $conn->prepare("INSERT INTO CREWMEMBERS (CREWID, MEMBER) VALUES (:crewid, :member)"); $query_params = array( ':crewid' => $crewid, ':member' => $value ); $stmt->execute($query_params); $response["success"] = 1; } catch(PDOException $e) { //echo 'ERROR: ' . $e->getMessage(); $response["success"] = 3; } } I always get org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
When I send $_POST['params'] to myself in email to see how it looks like, I get
{"params_0":"000000000284","params_1":"000000000229","params_2":"000000000081"} How do I handle these items separately?