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

  • SEARCH
  • Home
  • 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 7877313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:20:12+00:00 2026-06-03T03:20:12+00:00

I’m a beginner in developing Android apps and it’s the first time I’d be

  • 0

I’m a beginner in developing Android apps and it’s the first time I’d be coding from scratch that’s why I find it very hard for me. Basically, I just want to get rid of the error so that I can now start with displaying the SQL table on my Android application. I am barred by this error as I was fetching the data from mySQL tables. I am getting this at LogCat:

Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
05-03 15:45:25.586: W/System.err(552): java.lang.NullPointerException
05-03 15:45:25.626: W/System.err(552):  at hs.stockapp.StocksTask.doInBackground(StocksTask.java:64)

If I understood the error right, something’s wrong with line 64 of my StocksTask.java file.

Line 64: if (json.getString(KEY_SUCCESS) != null)

StocksTask.java code excerpt:

protected Integer doInBackground(String... params)  {

    UserFunctions userFunction = new UserFunctions();
    JSONObject json = userFunction.findStocks();
    try {
        if (json.getString(KEY_SUCCESS) != null) {
            String res = json.getString(KEY_SUCCESS);

            if(Integer.parseInt(res) == 1){         
                DatabaseHandler db = new DatabaseHandler(activity.getApplicationContext());
                JSONObject json_stocks = json.getJSONObject("stocks");
                Log.v("company_name", json_stocks.getString(STOCK_COMPANY_NAME));
                userFunction.findStocks();
                db.findStocks(json_stocks.getString(STOCK_COMPANY_NAME), json_stocks.getString(STOCK_SYMBOL), json_stocks.getString(STOCK_MCAP));                        

                responseCode = 1;
                // Close Screen
                //finish();
            }else{
                responseCode = 0;
                // Error 
            }
        }
    }
    catch (NullPointerException e) {
        e.printStackTrace();
    }
    catch (JSONException e) {
        e.printStackTrace();
    }
    return responseCode;
}

UserFunctions.java

 public JSONObject findStocks(){
    // Building Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("tag", findstocks_tag));
    JSONObject json = jsonParser.getJSONFromUrl(stocksURL, params);
    // return json
    return json;
} 

index.php

else if ($tag == 'stocks'){
    // request type is view stock list
    $stocks = $db->search_stocks();
    if ($stocks != false) {
        // stocks
        // echo json with success = 1
        $response["success"] = 1;
        $response["stocks"]["company_name"] = $stocks["name"];
        $response["stocks"]["com_sym"] = $stocks["com_sym"];
        $response["stocks"]["mkt_cap"] = $stocks["mkt_cap"];
        echo json_encode($response);
    } else {
        // no stocks found
        // echo json with error = 0
        $response["error"] = 1;
        $response["error_msg"] = "No stocks found";
        echo json_encode($response);
    }

} 

DB_functions.php

    public function search_stocks() {
    $result = mysql_query("SELECT company_name, com_sym, mkt_cap from stock ORDER BY com_sym") or die(mysql_error());
    $no_of_rows = mysql_num_rows($result);

    if ($no_of_rows > 0) {
        while($row=mysql_fetch_assoc($result)){
            $output[] = $row;
        }               
        print(json_encode($output)); 
        return $row;            
    return true;
    } else {
        // stocks not existed
        return false;
    }
mysql_close();  

}

Produced result of search_stocks function

[{"company_name":"Asian Chorva","com_sym":"ASIA","mkt_cap":"4534356"},{"company_name":"Banko de Oro","com_sym":"BDO","mkt_cap":"54434"},{"company_name":"Bank of the Phil Island","com_sym":"BPI","mkt_cap":"5464554"},{"company_name":"College Hive In Boon","com_sym":"CHIB","mkt_cap":"5434654"},{"company_name":"Critical Heart Throb Racing","com_sym":"CHTR","mkt_cap":"53544564654"}]

What should I do with Line 64?? MANY THANKS 🙂 Any help will be greatly appreciated. Additional info about it will be very helpful.

  • 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-03T03:20:13+00:00Added an answer on June 3, 2026 at 3:20 am

    The error message says:

    Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject

    If it is <!DOCTYPE then it isn’t [{"company_name":….

    You need to figure out exactly what request is being made and why the server is returning an HTML document.

    Check your server logs. It might be an error document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.