title: How can I view the string sent from httppost?
body: <p>Below is a snippet of code that is trying to post to a PHP script on a local server. I'm transmitting data back to the server's MySQL table and as the amount of data is very small, I thought I'd use HttpClient to embed the data in the URL arguments.</p>
  
  <p>However, even though the response I'm getting from the server is OK (HTTP code = 200), it's clear that the server-side PHP script is not getting correctly formatted data (there is no effect on the MySQL table). However, when I manually enter the URL+args in a browser like so: </p>
  
  <pre><code>http://10.0.0.13/jobs_returndata_test.php?jobnum=189193&amp;pnum=3&amp;entime=13:00&amp;extime=14:00 
  </code></pre>
  
  <p>for example, everything works fine (the PHP scripts writes correctly to the MySQL table).</p>
  
  <p>My question: Is there a way I can actually view what is being sent by HttpClient? (ie, the entire .toString contents of the HttpPost object?).  Here's the Android-side snippet:</p>
  
  <pre><code>// Create a new HttpClient and Post Header, send data as args to PHP file
  HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("http://10.0.0.13/jobs_returndata.php");
  try {
      List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
      nameValuePairs.add(new BasicNameValuePair("jobnum",convertSimple(jobNum)));
      nameValuePairs.add(new BasicNameValuePair("pnum",convertSimple(rowNum)));
      nameValuePairs.add(new BasicNameValuePair("entime",enteredInTime));
      nameValuePairs.add(new BasicNameValuePair("extime",enteredOutTime));
  
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      Log.i("HTTP Post", "Execute Post sending jobnum="+ convertSimple(jobNum) +      
      "&amp;pnum="+ convertSimple(rowNum) + "&amp;entime=" + enteredInTime
                      + "&amp;extime=" + enteredOutTime);
      // Execute HTTP Post Request
      HttpResponse response = httpclient.execute(httppost);
      Log.i("HTTP Post", "Response from server = " + response.getStatusLine().getReasonPhrase() + "  Code = " + convertSimple(response.getStatusLine().getStatusCode()));
  
          } catch (ClientProtocolException e) {
              Log.e("HTTP Post", "Protocol error = " + e.toString());
          } catch (IOException e) {
              Log.e("HTTP Post", "IO error = " + e.toString());
          }
  </code></pre>
  
  <p>And my server-side PHP file is:</p>
  
  <pre><code>?php
  $jobnum=$_GET['jobnum'];
  //echo "jobnum = $jobnum &lt;br /&gt;";
  $pnum=$_GET['pnum'];
  //echo "pnum = $pnum &lt;br /&gt;";
  
  $entime=$_GET['entime'];
  //echo "entime = $entime &lt;br /&gt;";
  
  $extime=$_GET['extime'];
  //echo "extime = $extime &lt;br /&gt;";
  
  
  $dbh=mysql_connect ("localhost", "Steve", "pluggin");
  mysql_select_db ("DriverJobs");
  
  $result = mysql_query("UPDATE jobs SET EntryTime = '$entime' WHERE JobNumber = '$jobnum' AND PointNum = '$pnum' ");  
  $result = mysql_query("UPDATE jobs SET ExitTime = '$extime' WHERE JobNumber = '$jobnum' AND PointNum = '$pnum' ") ;  
  
  //echo "done &lt;br /&gt;";
  ?&gt;
  </code></pre>
  
  <p>The logcat for the relevant section:</p>
  
  <blockquote>
    <p>06-22 13:33:11.341: I/HTTP Post(27788): Execute Post sending
    jobnum=189193&amp;pnum=3&amp;entime=9:00&amp;extime=9:05  06-22 13:33:11.581:
    I/HTTP Post(27788): Response from server = OK  Code = 200</p>
  </blockquote>
  
  <p>Permissions are good (in the Manifest file for INTERNET, and for the PHP file, Apache2 is on and running, API=8, using Eclipse with Android emulator). <em>convertSimple()</em> is a 2 liner that returns the String equivalent for an int primitive.</p>
  
  <p>Thanks in advance for looking at this!</p>