List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
params.add(new BasicNameValuePair("id", android_id));
JSONObject json = jParser.makeHttpRequest("http://cp1.be/scriptsandroid/dbvoorbeeld2.php", "POST", params);
try {
// Checking for SUCCESS TAG
int success = json.getInt("success");
if (success == 1) {
}
} catch (JSONException e) {
e.printStackTrace();
}
So like the title says that is the error I'm getting. I've been searching for the answer but did not find it yet. Thanks in advance.
My php file:
<?php
if(isset($_POST['id'])) {
$key = $_POST['id'];
require_once("db_licentieserver.php");
$response["success"] = 1;
echo json_encode($response);
} else {
$response["success"] = 0;
echo json_encode($response);
}
?>
Imported this in my java project:
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;