Click here to Skip to main content
15,939,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send userid to server and fetch the data related to the userid in android using Volley connectivity and php script But i am getting Error like : org.json.JSONException: Value UserId of type java.lang.String cannot be converted to JSONObject

other Error Like :End of Input character 0 of

Help me to Solve the problem...

What I have tried:

Below is php file


    require "connect.php";
    $userId = $_GET['UserId'];
    $query = "SELECT * FROM `executive` WHERE ExecutiveId = '$userId'";
    $result = mysqli_query($conn, $query);
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_assoc($result)){
           echo json_encode($row);
    } else {
        echo "UserId :".$userId."Not Found";


Below code is from android file

public void getExecutiveInfo(){

        String url = "";

        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
            public void onResponse(JSONObject response) {

                Log.d("Reponse", response.toString());

        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError error) {
                Log.d("Error Response", error.toString());

            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String> params = new HashMap<>();
                return params;



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900