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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:29:22+00:00 2026-06-14T16:29:22+00:00

This post request goes to a php page that connects to my database that

  • 0

This post request goes to a php page that connects to my database that queries whatever is in the textfield “name”. The string that is appended to results is always null when I know for a fact they are not null. What am I miss?

public void onClick(View v) {
    URI website = null;
    HttpResponse response = null;
    BufferedReader in = null;
    InputStream is = null;
    String result = "hello";
    JSONObject jArray = null;


    HttpClient client = new DefaultHttpClient();

    try {
        website = new URI("http://fakesite.com");
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    HttpGet getRequest = new HttpGet();
    getRequest.setURI(website);

    HttpPost postRequest = new HttpPost(website);


    try {

        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("name", name.toString() ));
        postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        response = client.execute(postRequest);

        HttpEntity entity = response.getEntity();
        is = entity.getContent();

        results.append(" got response");
    } 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) {
            sb.append(line + "\n");
        }

        is.close();
        result=sb.toString();

        results.append(result);

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

}
  • 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-14T16:29:23+00:00Added an answer on June 14, 2026 at 4:29 pm

    nameValuePairs.add(new BasicNameValuePair(“name”, name.toString() ));

    what is name in name.toString(). Where are you initialising the name object?

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

Sidebar

Related Questions

I wanted to make a post request in this website: http://www.prezup.info/index.php?page=films in order to
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
I just posted this question jQuery - passing arrays in post request , where
I want to make a HTTP Post request from C#. This request has a
this is the code: def create(request, form_class=MapForm, template_name=maps/create.html): map_form = form_class(request.POST or None) if
My code is somewhat like this: <?php if($_REQUEST['post']) { $title=$_REQUEST['title']; $body=$_REQUEST['body']; echo $title.$body; }
Django code samples involving post data often shows code similar to this: if request.method
Edited at the request of commenters. I hope this is compliant. First post! Trying
I have this post request code in jquery, which seems to send the request
The page's link is: localhost/mysite/create-user This is the code: <form class=form-horizontal name = signUp1F

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.