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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:49:54+00:00 2026-06-01T06:49:54+00:00

Trying to have my PHP script return some SQL table queries. Here’s my script

  • 0

Trying to have my PHP script return some SQL table queries. Here’s my script as it stands right now:

<?php

define("DB_HOST", "localhost");
define("DB_USER", "*");
define("DB_PASSWORD", "*");
define("DB_DATABASE", "*");

mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_DATABASE);


if (isset($_POST['tag']) && $_POST['tag'] != '') {
    $tag = $_POST['tag'];
    echo $tag;
if ($tag == 'question') {
    $category = $_POST['category'];
    $response=mysql_query("select * from QUESTIONS where CATEGORY like '$category'");
    return $category; //just doing this, rather than $response to see if it works
}
}
?>

And here’s the Android code that’s associated with it:

public JSONObject getQuestionsJSONFromUrl(String url, List<NameValuePair> params) {

    // Making HTTP request
try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(new UrlEncodedFormEntity(params));

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            Log.v("while", line);
            sb.append(line + "\n");
            //Log.v("err", line);
        }
        is.close();

And the method that calls getQuestionsJSON…:

private static String question_tag = "question";
public JSONObject getQuestions(String category) {
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("tag", question_tag));
    params.add(new BasicNameValuePair("category", category));
    //JSONObject json;
    JSONObject questionsList = jsonParser.getQuestionsJSONFromUrl(questionURL, params);
    //return json
    return null;
}

And here’s the LogCat of the Log.v() I have in the getQuestionsJSON…() method:

04-04 20:41:58.721: V/while(933): question

So I don’t really see why this is returning ‘question’ rather than the String that is passed when I run getQuestions()?

  • 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-01T06:49:56+00:00Added an answer on June 1, 2026 at 6:49 am

    In PHP file you have

    echo $tag;
    

    And it is response to request.

    This should return mysql response:

    if (isset($_POST['tag']) && $_POST['tag'] != '') {
        $tag = $_POST['tag'];
        if ($tag == 'question') {
            $category = $_POST['category'];
            $response=mysql_query("select * from QUESTIONS where CATEGORY like '$category'");
    
            $rows = array();
            while($r = mysql_fetch_assoc($response)) {
                $rows[] = $r;
            }
            print json_encode($rows);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a PHP script that will return some details of each
I'm trying to make a PHP script, I have the script finished but it
I am trying to make a Postgres PHP backup script. I have downloaded one
Help! I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to
I am trying to fetch a PHP script using AJAX and return the values
I have some troubles with encoding and mailing. I send post-request to php-script, when
I am trying to send a php script some content to be stored in
I've trying to learn PHP OOP and have made some research on how to
I'm trying to synchronize the timezone between a PHP script and some JavaScript code.
I am trying to have a php script that displays a url with user

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.