title: Values are in text view not passed to the Mysql database
body: <p>In my android app i am getting latitude and longitude for textview and then i m trying to pass them to the Mysql DB.MySql Db has created locally..My db has 3 fields id(auto incremented) latitude and longitude(double).No log cat errores</p>
  
  <p>Here is My Main Activity</p>
  
  <pre><code>package com.example.newgps;
  
  import java.io.BufferedReader;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;
  import org.json.JSONObject;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  
  import android.location.Criteria;
  import android.location.Location;
  import android.location.LocationListener;
  import android.location.LocationManager;
  
  import android.app.Activity;
  import android.content.Context;
  import android.util.Log;
  
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  public class MainActivity extends Activity implements LocationListener{
  
    LocationManager lm;
    TextView lt, ln;
    String provider;
    Location l;
    int code;
    InputStream is=null;
    String result=null;
    String line=null;
    Button button1;
    String latitude;
    String longitude;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
  
     ln=(TextView)findViewById(R.id.lng);
     lt=(TextView)findViewById(R.id.lat);
     Button button1=(Button) findViewById(R.id.button1);
  
     button1.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub  
              latitude= lt.getText().toString();
              longitude = ln.getText().toString();
  
              insert();
          }
      });
  
     lm=(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
     Criteria c=new Criteria();
  
     provider=lm.getBestProvider(c, false);
  
     l=lm.getLastKnownLocation(provider);
     if(l!=null)
     {
       //get latitude and longitude of the location
       double lng=l.getLongitude();
       double lat=l.getLatitude();
  
  
       ln.setText(""+lng);
       lt.setText(""+lat);
     }
     else
     {
      ln.setText("No Provider");
      lt.setText("No Provider");
     }
    }
  
     @Override
     public void onLocationChanged(Location arg0)
     {
      double lng=l.getLongitude();
      double lat=l.getLatitude();
      ln.setText(""+lng);
      lt.setText(""+lat);
     }
  
  
  
  
     public void insert ()
     {
      final ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
  
      nameValuePairs.add(new BasicNameValuePair("latitude",latitude));
      nameValuePairs.add(new BasicNameValuePair("longitude",longitude));
  
      class RetrieveFeedTask extends AsyncTask&lt;String, Void, String&gt; {
  
          private Exception exception;
          protected String doInBackground(String... urls) {
  
      try
      {
          HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost("http://192.168.1.31/gpstracking/insert.php");
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
              HttpResponse response = httpclient.execute(httppost); 
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
              Log.e("pass 1", "connection success ");
      }
  
      catch(Exception e)
      {
          Log.e("Fail 1", e.toString());
              Toast.makeText(getApplicationContext(), "Invalid IP Address",
              Toast.LENGTH_LONG).show();
      }     
  
         try
         {
             BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
             StringBuilder sb = new StringBuilder();
             while ((line = reader.readLine()) != null)
          {
                 sb.append(line + "\n");
             }
             is.close();
             result = sb.toString();
          Log.e("pass 2", "connection success ");
      }
         catch(Exception e)
      {
             Log.e("Fail 2", e.toString());
      }     
  
      try
      {
             JSONObject json_data = new JSONObject(result);
             code=(json_data.getInt("code"));
  
             if(code==1)
             {
          Toast.makeText(getBaseContext(), "Inserted Successfully",
              Toast.LENGTH_SHORT).show();
             }
             else
             {
           Toast.makeText(getBaseContext(), "Sorry, Try Again",
              Toast.LENGTH_LONG).show();
             }
      }
      catch(Exception e)
      {
             Log.e("Fail 3", e.toString());
      }
      return latitude;
  
      }
      }}
    @Override
    public void onProviderDisabled(String arg0) {
     // TODO Auto-generated method stub
    }
    @Override
    public void onProviderEnabled(String arg0) {
     // TODO Auto-generated method stub
    }
  
    @Override
    public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
     // TODO Auto-generated method stub
    }
  }
  </code></pre>
  
  <p>Here is my Php script</p>
  
  <pre><code>    &lt;?php
  
  
          $host='localhost';
          $uname='root';
          $pwd='';
          $db="gps";
  
          $con = mysql_connect($host,$uname,$pwd) or die("connection failed");
          mysql_select_db($db,$con) or die("db selection failed");
  
          $latitude=$_REQUEST['latitude'];
          $longitude=$_REQUEST['longitude'];
  
          $flag['code']=0;
  
          if($r=mysql_query("insert into location values('$latitude','$longitude') ",$con))
          {
              $flag['code']=1;
              echo"hi";
          }
  
          print(json_encode($flag));
          mysql_close($con);
      ?&gt;
  </code></pre>