Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:44:37+00:00 2026-06-17T18:44:37+00:00

.Java file. This is where error is—> int success = json.getInt(TAG_SUCCESS); protected String doInBackground(String…

  • 0

.Java file. This is where error is—> int success = json.getInt(TAG_SUCCESS);

       protected String doInBackground(String... args) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        // getting JSON string from URL
        JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

        // Check your log cat for JSON reponse
        Log.d("All Products: ", json.toString());

        try {
            // Checking for SUCCESS TAG
            **int success = json.getInt(TAG_SUCCESS);**

            if (success == 1) {
                // products found
                // Getting Array of Products
                products = json.getJSONArray(TAG_PRODUCTS);
                Log.d("level1: ", "@@@@@@@@@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");

                // looping through All Products
                for (int i = 0; i < products.length(); i++) {
                    JSONObject c = products.getJSONObject(i);

                    // Storing each json item in variable
                    String id = c.getString(TAG_PID);
                    String name = c.getString(TAG_NAME);
                    Log.d("level2: ", "lksdjflsdjf0wrewrwje************************");
                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();

                    // adding each child node to HashMap key => value
                    map.put(TAG_PID, id);
                    map.put(TAG_NAME, name);

                    // adding HashList to ArrayList
                    productsList.add(map);
                }
            } else {
                // no products found
                // Launch Add New product Activity
                Log.d("level3: ", "jldksffffffffffffffffffffffffffffffffffffff");
                Intent i = new Intent(getApplicationContext(),
                        NewProductActivity.class);
                // Closing all previous activities
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

Json Array from server is below. I have validated it from jsonlint.com

     {
"tbl_user": {
    "0": {
        "id": "195",
        "email": "aru@yahoo.com",
        "password": "202cb962ac59075b964b07152d234b70",
        "fname": "aru",
        "lname": "sharma"
    },
    "1": {
        "id": "196",
        "email": "manu@yahoo.com",
        "password": "202cb962ac59075b964b07152d234b70",
        "fname": "manu",
        "lname": "sharma"
    },
    "2": {
        "id": "197",
        "email": "rishi@yahoo.com",
        "password": "202cb962ac59075b964b07152d234b70",
        "fname": "rishi",
        "lname": "sharma"
    },
    "success": 1
}

}

I think I am unable to read success value from here. I am unable to see the error in this Json string. Please help.

Rest Php code on server creating json is

    function getUsers() {
$sql = "select * FROM tbl_user ORDER BY fname";
try {
    $db = getConnection();
    $stmt = $db->query($sql);  
    $users = $stmt->fetchAll(PDO::FETCH_OBJ);
    $users["success"] = 1;
    $db = null;
    echo '{"tbl_user": ' . json_encode($users) . '}';

} catch(PDOException $e) {
    echo '{"error":{"text":'. $e->getMessage() .'}}'; 
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:44:39+00:00Added an answer on June 17, 2026 at 6:44 pm

    Try this:

    PHP:

    try {
    $db = getConnection();
    $stmt = $db->query($sql);  
    $users["tbl_user"] = $stmt->fetchAll(PDO::FETCH_OBJ);
    $users["success"] = 1;
    $db = null;
    echo json_encode($users) 
    
    } catch(PDOException $e) {
    echo '{"error":{"text":'. $e->getMessage() .'}}'; 
    }
    

    and in java file:

    JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
    int success = json.getInt(TAG_SUCCESS);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hai friends...my java file indicate this error: R.styleable cannot be resolved.... my xml file:
when i want to open java file to edit I get this error Could
I keep getting this error 07-28 19:32:40.536: ERROR/error(534): java.io.IOException: No such file or directory
I am getting this error when I try to open a file: java.io.FileNotFoundException: D:\Portable%20Programs\Android%20Development\workspace3\XXX-desktop\bin\World_X.fr
I am trying to compile a Java file and I'm getting this error message:
I've got this error message when I compiled a Java file : error: package
In documentation code I see some things like this: /* * @(#)File.java 1.142 09/04/01
This is my Database structure, One-to-One mapping in MySQL: This is my java file:
I am trying this import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream;
I have a file in .gz format. The java class for reading this file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.