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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:23:16+00:00 2026-05-29T16:23:16+00:00

I have just started connecting android app with php My file works very fine

  • 0

I have just started connecting android app with php
My file works very fine when i run on local wamp server
After uploading on remote server , I am getting what i want but i am getting some extra code on my emulator. I want to get rid of it
Please help.
When i call the same file in my chrome using an html file then also it works fine.

Here is code of my android app

public class LoginActivity extends Activity {

HttpClient hc;
HttpPost hp;
List<NameValuePair> nvp;
HttpResponse hr;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final EditText username=(EditText) findViewById(R.id.username);
    final  EditText password=(EditText) findViewById(R.id.password);
    Button b=(Button) findViewById(R.id.register);
    final  TextView res=(TextView) findViewById(R.id.textView3);

    b.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // String result="Username: "+username.getText().toString()+"\n"+"Password: "+password.getText().toString(); 
            //res.setText(result);
            try
            {
                hc=new DefaultHttpClient();
                hp=new HttpPost("http://pratik30.host56.com/insertquery.php");
                nvp=new ArrayList<NameValuePair>(2);
                nvp.add(newBasicNameValuePair("username", username.getText().toString()));
                nvp.add(new BasicNameValuePair("password", password.getText().toString()));
                hp.setEntity(new UrlEncodedFormEntity(nvp));
                //hr=hc.execute(hp);
                ResponseHandler<String> rs= new BasicResponseHandler();
                String r=hc.execute(hp,rs);
                res.setText(r);
            }
            catch(Exception e)
            {
                res.setText(e.getLocalizedMessage());   
            }
        }
    });
}

}

Here is the php file

<?php
    $dbc=mysqli_connect('localhost','root','mypassword','pratik') or die('Error connecting to mysql server');
    $user=$_POST['username'];
    $pass=$_POST['password'];
    echo $user;
    echo $pass;
    $query = "Insert into users values ('$user','$pass');";
    $result=mysqli_query($dbc,$query) or die('Error querying database');
    mysqli_close($dbc);
?>

Here is a picture of the output I am getting.

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

    Your php returns the following you have to remove it from there:

    <!-- www.000webhost.com Analytics Code -->
    
    <script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
    
    <noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
    
    <!-- End Of Analytics Code -->
    

    you’re setting the whole result text into your
    TextView res.setText(r);


    hope it helps.

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

Sidebar

Related Questions

I'm just getting started with adding admob to my android app and have started
I have just started using Boost 1.36. These libraries would be very useful in
I have just started building a app using XihSolutions.DotMSN.dll version: 2.0.0.40909, My problem is
I have just started the Hello World App using Blackberry Eclipse Plugin. I have
i literally just started looking into php, connecting to a remote database and returning
I just started experimenting with java today (have experience with javascript and PHP) and
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I have just started using silverlight 2 beta and cannot find how to or

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.