title: Send data from android to php
body: <p>I need to help about to send data from android to php. I have this java code for android;</p>
  
  <pre><code>public void sendToDb()
  {
      ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
      nameValuePairs.add(new BasicNameValuePair("pLat",Double.toString(lat)));
      nameValuePairs.add(new BasicNameValuePair("pLng",Double.toString(lng)));
  
      try{
          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new      
                  HttpPost("http://123456.com/welcome.php");
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = httpclient.execute(httppost);
          Log.i("postData", response.getStatusLine().toString());
      }
  
      catch(Exception e)
      {
          Log.e("log_tag", "Error in http connection "+e.toString());
      }           
  }
  </code></pre>
  
  <p>and I have in my php folder this codes;</p>
  
  <pre><code>&lt;?php
   $pLat = $_POST['pLat'];
   $pLng = $_POST['pLng'];
  
   $result = mysql_query("update Users set lat='$pLat',lon='$pLng' where username='ozi');      
   if (mysql_affected_rows()==0) 
     {
      $query = "INSERT INTO Users ";
      $query .= "(lat,lon) VALUES ('$pLat','$pLng')";
     }
   }
  ?&gt;
  </code></pre>
  
  <p>When I send to data from my phone there is no problem but after I look mysql lat and lot rows not null but empty.
  Is there a problem that you see in codes?</p>