I'm trying to connect android with php and also mysql using json. This is apart of my coding which is to add data.

Based on the coding 

**private static String url\_create\_fixture = "http:// android\_connect/create\_product.php";** 

What should be the ip address if I'm testing this application through android phone instead of the emulator?

Another question, I tested this application on the phone and it says that **process.com.example.mobile\_fixtures has stopped working unexpectedly. Please try again.** 

Is this because of the wrong ip or there is something wrong with my process?

```
package com.example.mobile_fixtures;

public class NewFixturesActivity extends Activity {

// Progress Dialog
private ProgressDialog pDialog;

JSONParser jsonParser = new JSONParser();
EditText inputDate;
EditText inputTime;
EditText inputStadium;
EditText inputHome;
EditText inputAway;

// url to create new product
private static String url_create_fixtures = "http://10.1.1.6/android_connect/create_product.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_fixtures);

    // Edit Text
    inputDate = (EditText) findViewById(R.id.inputDate);
    inputTime = (EditText) findViewById(R.id.inputTime);
    inputStadium = (EditText) findViewById(R.id.inputStadium);
    inputHome = (EditText) findViewById(R.id.inputHome);
    inputAway = (EditText) findViewById(R.id.inputAway);

    // Create button
    Button btnCreateProduct = (Button) findViewById(R.id.btnCreateProduct);

    // button click event
    btnCreateProduct.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // creating new product in background thread
            new CreateNewProduct().execute();
        }
    });
}

/**
 * Background Async Task to Create new product
 * */
class CreateNewProduct extends AsyncTask<String, String, String> {

    /**
     * Before starting background thread Show Progress Dialog
     * */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(NewFixturesActivity.this);
        pDialog.setMessage("Creating Fixtures..");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    /**
     * Creating product
     * */
    protected String doInBackground(String... args) {
        String date = inputDate.getText().toString();
        String time = inputTime.getText().toString();
        String stadium = inputStadium.getText().toString();
        String home = inputHome.getText().toString();
        String away = inputAway.getText().toString();

        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("date", date));
        params.add(new BasicNameValuePair("time", time));
        params.add(new BasicNameValuePair("stadium", stadium));
        params.add(new BasicNameValuePair("home", home));
        params.add(new BasicNameValuePair("away", away));

        // getting JSON Object
        // Note that create product url accepts POST method
        JSONObject json = jsonParser.makeHttpRequest(url_create_fixtures,
                "POST", params);

        // check log cat fro response
        Log.d("Create Response", json.toString());

        // check for success tag
        try {
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // successfully created product
                Intent i = new Intent(getApplicationContext(), AllFixturesActivity.class);
                startActivity(i);

                // closing this screen
                finish();
            } else {
                // failed to create product
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    /**
     * After completing background task Dismiss the progress dialog
     * **/
    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();
    }

}
}

```