Tutorial: Connect Android with PHP, MySQL [Example Code]


Android app that will call PHP script to perform basic CRUD(Create, Read, Update, Delete) operations. Take this as a standard practice. Things we need for successful operations

1. WAMP Server

WAMP is acronym for Windows, Apache, MySQL and PHP, Perl, Python. WAMP software is one click installer which creates an environment for developing PHP, MySQL web application. By installing this software you will be installing ApacheMySQL and PHP. Alternatively you can use XAMP Server also.

2. Installing and Running WAMP Server

Download & Install WAMP server from www.wampserver.com/en/. Once you have installed wamp server, launch the program from Start -> All Programs -> WampServer -> StartWampServer.

You can test your server by opening the address http://localhost/ in browser.

Also you can check phpmyadmin by opening http://localhost/phpmyadmin

3. PHP Project

Now you have the environment ready to develop a PHP & MySQL project. Go to the location where you installed WAMP server (In my case i installed in C:\wamp\) and go to www folder and create a new folder for your project. You have to place all your project files inside this folder.

Create a folder called android_connect and create a new php file called test.php and try out simple php code. After placing following code try to open http://localhost/android_connect/test.php and you should see a message called “Welcome, I am connecting Android to PHP, MySQL“.



echo “Welcome, I am connecting Android to PHP, MySQL”;


Following is a screen cast of Creating and Running a simple PHP project.