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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:56:27+00:00 2026-06-04T18:56:27+00:00

I am trying to access a database through a simple PHP code. But the

  • 0

I am trying to access a database through a simple PHP code. But the constraints are that it is a remote database, accessed by a remote server from a real device.

here is a snippet of the code:-

ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("username", un.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", pw.getText().toString()));
            String response = null;
            try {
                response = CustomHttpClient.executeHttpPost("http://WebsiteName.com/check.php", postParameters);
                String res=response.toString();

                res= res.replaceAll("\\s+","");                              

               if(res.equals("1"))
                    error.setText("Correct Username or Password");
                else
                    error.setText("Sorry!! Incorrect Username or Password"); 
            } catch (Exception e) {
                un.setText(e.toString());
            }

The PHP is here. Most probably there is no problem with the PHP code because it works locally.

One of the most important things I want to clarify is where to keep the PHP code in the server. I have it directly under the root directory. When i execute it from the browser (say by typing website.com/check.php), i get the required response.
Unfortunately many people who have given a tutorial on this, has mentioned about local server and local database more than remote ones. Is there something more I should do for getting it done with a real device?

PS: The app works fine when connected to an emulator and local database with local webserver.

===UPDATE===

I am pretty sure that the phone is not contacting the web server. I verified by making the webserver give a positive response always, which also failed. Any hints on where I should look at? I can’t think of anything other than the online server…which is working (when checked from browser). Any way of cross checking it? Thanks.

  • 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-04T18:56:29+00:00Added an answer on June 4, 2026 at 6:56 pm

    This may or may not be the cause of the problem you are facing, but you must fix it either ways.

    You are currently making the POST request synchronously. That means, as long as the POST request is executing and the device is awaiting a response, the phone and UI is locked up. Not only does this make for a bad user experience, if you lock up the UI thread for more than a certain amount of time, Android considers the application to have crashed.

    Perhaps that is why it works when you make the request locally, because a POST request to your local webserver will be very quick as opposed to a remote webserver.

    To make a HTTP request, asynchronously, look into Android AsyncTask

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

Sidebar

Related Questions

I'm trying to write bits of code to a Microsoft access database from Delphi.
I'm trying to access a large Oracle database through SQL Server using OPENROWSET in
I am trying to access database from a Class Library Project. I have connection
I am trying to launch an existing MS Access database (Access 2010) from a
i am trying to establish a connection with access database using java... But while
I am trying to Update a table in an access database from C#. It
I'm trying to retrieve record data from an MS-Access database and store it into
I'm trying to autocomplete a textbox. I'm retrieving values from Access Database. Just one
I am trying to access an SQLite 3 database programmatically using the code below:
I'm trying to access a MySQL database through Silverlight, and I know you 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.