A
Anojo
Neues Mitglied
- 1
Hi an alle,
hab über Android ein JsonObject erstellt das ich an PHP übergeben will und anschließend will ich wieder was zurück geben.
Das Json mach ich so...
Dann hier noch mein PHP Script...
postList = {"19":74,"17":71,"18":73,"15":67,"16":68,"13":65,"14":66,"11":63,"12":64,"21":76,"20":75,"22":78,"23 ":79,"24":84,"25":103,"26":112,"27":113,"28":114,"29":118,"3":54,"2":53,"10":62,"1":34,"0":32,"7":58 ,"6":57,"5":56,"4":55,"9":60,"8":59}
Zurück bekomme ich ein false statt der erhofften Daten aus der Datenbank.
Was mach ich falsch?

Gruß Toni

hab über Android ein JsonObject erstellt das ich an PHP übergeben will und anschließend will ich wieder was zurück geben.
Das Json mach ich so...
Code:
private JSONObject postList = new JSONObject();
if(fertig || notFertig == 30){
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("postList", postList.toString()));
try {
Log.d(TAG, "Verbindung zur Datenbank wird hergestellt!");
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://localhost/test.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httppost.setHeader("Accept", "application/json");
httppost.setHeader("Content-type", "application/json");
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {...
...
...
...
} else {
try {
postList.put(""+ notFertig, id);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
notFertig++;
}
Dann hier noch mein PHP Script...
PHP:
...
....
$list = $_REQUEST['postlist'];
$list = json_decode(utf8_encode($list));
$in = "";
for($i = 0; $i <= 30; $i++){
if($list[$i] != ""){
if($in !=""){
$in += ', ';
}
}
$in += $list[$i];
}
$q=mysql_query( "SELECT * FROM daten WHERE `id` IN ($in)");
...
...
postList = {"19":74,"17":71,"18":73,"15":67,"16":68,"13":65,"14":66,"11":63,"12":64,"21":76,"20":75,"22":78,"23 ":79,"24":84,"25":103,"26":112,"27":113,"28":114,"29":118,"3":54,"2":53,"10":62,"1":34,"0":32,"7":58 ,"6":57,"5":56,"4":55,"9":60,"8":59}
Zurück bekomme ich ein false statt der erhofften Daten aus der Datenbank.
Was mach ich falsch?


Gruß Toni
Zuletzt bearbeitet: