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 8901563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:23:15+00:00 2026-06-15T01:23:15+00:00

I’ve been trying to make an application which has very rich Database mySQL with

  • 0

I’ve been trying to make an application which has very rich Database mySQL with PHP support on 000webhost. We’re trying to calculate the mood of the person.

There are two tables Colour and Element from which i’m picking the Score on the basis of Colour_ID and Element_ID. Actually i took Colour_ID and Element_ID value from the user by android Application and passed it through JSON PARSING.

The Code of mood.php is:

<?php
$response = array();

if (isset($_POST['Colour']) && isset($_POST['Element'])) { 

$colour = $_POST['Colour'];
$element = $_POST['Element'];  

$con = mysql_connect("mysql1.000webhost.com","a4633783_snyz","software123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("a4633783_snyz", $con);

// get color id from color table

$result_colour = mysql_query("SELECT Score FROM COLOUR WHERE Colour_ID = $colour");

$result1 = mysql_fetch_array($result_colour);

$result_element = mysql_query("SELECT Score FROM ELEMENT WHERE Element_ID = $element");

$result2 = mysql_fetch_array($result_element);

$main_result = ($result1[0] + $result2[0]);

$mood=mysql_query("SELECT Mood FROM CHECK_MOOD WHERE Score = $main_result");

$row = mysql_fetch_array($mood);

$response["mood"]=array();
array_push($response["mood"], $row);

// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No mood available";
// echo no users JSON
echo json_encode($response);
}
?>

Now what i want is that when user select 1 as Colour_ID and 1 as Element_ID, the mood on the Score 2 should be displayed to him on this android application.

The Mood.java is:

public class mood extends Activity {

private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();

RadioGroup color;
RadioGroup element;
TextView JsonResult;
String mood_result;

// url to create new product
private static String url_create_signup = "http://snyz.site88.net/mood.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mood);
    color = (RadioGroup) findViewById(R.id.color);
    element = (RadioGroup) findViewById(R.id.element);
    JsonResult = (TextView) findViewById(R.id.json_result);

    // Create button
    Button btnCreateProduct = (Button) findViewById(R.id.submit);

    // button click event
    btnCreateProduct.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            new signup().execute();
        }
    });
}

/**
 * Background Async Task to Create new product
 * */
class signup extends AsyncTask<String, String, String> {

    int color_value = color.getCheckedRadioButtonId();
    int element_value = element.getCheckedRadioButtonId();

    /**
     * Before starting background thread Show Progress Dialog
     * */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(mood.this);
        pDialog.setMessage("Please wait!");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        // pDialog.show();
    }

    protected String doInBackground(String... args) {
        String Colour = Integer.toString(color_value);
        String Element = Integer.toString(color_value);

        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();

        params.add(new BasicNameValuePair("Colour", Colour));
        params.add(new BasicNameValuePair("Element", Element));

        // getting JSON Object
        // Note that create product url accepts POST method
        JSONObject json = jsonParser.makeHttpRequest(url_create_signup,
                "POST", params);

        // check log cat for response
        Log.d("Create Response", json.toString());

        // check for success tag
        try {
            int success = json.getInt(TAG_SUCCESS);
            if (success == 1) {

                JSONArray jArray = json.getJSONArray("ARRAYNAME");

                // for (int i = 0; i < jArray.length(); i++) {
                JSONObject oneObject = jArray.getJSONObject(0);
                // Pulling items from the array
                mood_result = oneObject.getString("STRINGNAMEinTHEarray");
                // String oneObjectsItem2 = oneObject
                // .getString("anotherSTRINGNAMEINtheARRAY");

                String JsonResultt = "\n\nYour mood is: " + mood_result;

                JsonResult.setText("\n" + JsonResultt);

                // display.show();
                // successfully created product
                // Intent i = new Intent(getApplicationContext(),
                // login.class);
                // startActivity(i);

                finish();
            } else {
                // failed to create product
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    /**
     * After completing background task Dismiss the progress dialog
     * **/
    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        // pDialog.dismiss();
    }
} }

But i’m not getting the desired Output and couldn’t even able to figure out the exact problem. My Logcat gives following Error:

Error parsing data org.json.JSONException: Value Your of type java.lang.String cannot be converted to JSONObject

Please help me where I’m making the mistake and Guide me properly How can i get my desired Output on my Android Application. Hoping to hear soon. Thanks in Advance!

  • 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-15T01:23:18+00:00Added an answer on June 15, 2026 at 1:23 am

    My guess is that you are outputting an array to JSON, but trying to parse into JSONObject. If you are encoding an array, you need to decode with JSONArray. Show your JSON in the question and I can verify this is the case.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't

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.