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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:12:41+00:00 2026-06-11T11:12:41+00:00

Code on the android device is: public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) { //

  • 0

Code on the android device is:

public JSONObject getJSONFromUrl(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) {
            sb.append(line + "n");
        }
        is.close();
        json = sb.toString();
        Log.e("JSON", json);
    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObj = new JSONObject(json);
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
    }

    // return JSON String
    return jObj;
    }

Code on the PHP server is:

    $name = $_POST['name'];
    $email= $_POST['email'];
    $password = $_POST['password'];

    $user = $db->storeUser($name, $email, $password);

    if($user){
            echo json_encode($response). "User Stored Successfully";
        } 
        else{
            echo json_encode($response). "Error Occured in Registration";
        }

where storeUser is:

    public function storeUser($name, $email, $password) {

    $result = mysql_query("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES('$uuid', '$name', '$email','$encrypted_password', '$salt', NOW())");

    }

The process works, sends a message back to the android device, but the details are not
inserted into the MySQL database?

All I want is to post the details from an android device and insert them into a MySQL database on my server.

Anyone know why this is being caused, what am I doing wrong?

  • 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-11T11:12:42+00:00Added an answer on June 11, 2026 at 11:12 am

    I figured out what was wrong with my code from above.

    The url passed to the httppost in the java/android code did not work as a simple address to the api I am using, I tried http://www.domain.com/index.php? with the ‘?’. Adding this made the code work.

    I just went back to basics, looking at what makes a post

    here is a reference to the POST article in wikipedia http://en.wikipedia.org/wiki/POST_(HTTP), it helped me to figure out what made up a http post

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

Sidebar

Related Questions

I am trying to debug a C++ native code on Android device using NDK.
I have the following code running on my Android device. It works great and
From my android code I try with the android browser to access a tomcat
I have this code in Android: Map<String, String> idObject1 = new LinkedHashMap<String, String>(); idObject1.put(Id,
I have a question about rotating the Android device. My code logs a static
I have the following Java code being used on an Android device that encrypts
I am writing code to get the mac address of any Android device having
I have written this code to try and stream a video to my Android
Hello I am receiving a JSON file from an URL in an Android device.
I am making and application to send data using sockets from an android device

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.