Using Android Volley to post an array to PHP -
Using Android Volley to post an array to PHP -
this how post values volley:
@override protected map<string, string> getparams() { jsonobject jsonobjectmembers=new jsonobject(); (int i=0; i<arr_added_userids.size(); i++) { seek { jsonobjectmembers.put("params_"+i,arr_added_userids.get(i)); } grab (jsonexception e) { e.printstacktrace(); } } map<string, string> params = new hashmap<string, string>(); params.put("host", session_userid); params.put("params",jsonobjectmembers.tostring()); homecoming params; }
this tried:
foreach($_post['params'] $key => $value) { seek { $stmt = $conn->prepare("insert 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 org.json.jsonexception: value <br of type java.lang.string cannot converted jsonobject
when send $_post['params'] myself in email see how looks like, get
{"params_0":"000000000284","params_1":"000000000229","params_2":"000000000081"}
how handle these items separately?
i have faced same problem. solution:
map<string, string> params = new hashmap<string, string>(); params.put("params[0]", "a"); params.put("params[1]", "b"); params.put("params[2]", "c");
php android mysql android-volley
Comments
Post a Comment