Connecting to MySQL database using PHP from Android device

I am trying to connect to MySQL using PHP from an Android device. I am following this tutorial:

My question is where does the php file you create go to? Is this included in your Android project or where do I run it?



source to share

3 answers

To answer your questions:

1) The php file is not included on android device.
2) You need to create a .php file and upload it to your server.

Now I'm not sure how much you know about php, but just in case you are a beginner, you can easily create .php files with a text editor application like Text Edit (Mac) or Notepad (Windows), you control the server or wherever- Anyone have a website? If so, you can download the file to the location you want.

How the php file works: First, your android device (after you finish this tutorial you provided) will send a request to a php file on your server and the php file will then connect to the MySQL database and generate the output which is yours Android application will be able to return (for example, find out the result of a MySQL connection attempt, etc.)

* Next> If you want a super simple php tutorial, check out W3 Schools' great php section:



The PHP file resides on the server, just like the MySQL database. This is shown in the first image in the tutorial. This server can be your computer, or it can be on a website. In the tutorial, an Android app makes a JSON call to a web server that uses PHP to query the database and returns the data to the app. In the example you linked to, the server address




Using the example link you posted, the server

HttpPost httppost = new HttpPost("");

PHP is a server-side language and is served by the client using an HTTP server. MySQL Serve can be on the same host or on a different one.

Read about PHP here ->



All Articles