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: http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/

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?

thank

0


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: http://www.w3schools.com/php/

+1


source


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 http://10.0.2.2/

.



0


source


Using the example link you posted, the server http://10.0.2.2/

HttpPost httppost = new HttpPost("http://10.0.2.2/city.php");

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 -> http://www.php.net/manual/en/intro-whatis.php

0


source







All Articles