Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:48:47+00:00 2026-06-06T14:48:47+00:00

Below is a snippet of code that is trying to post to a PHP

  • 0

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.

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:

http://10.0.0.13/jobs_returndata_test.php?jobnum=189193&pnum=3&entime=13:00&extime=14:00 

for example, everything works fine (the PHP scripts writes correctly to the MySQL table).

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:

// 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<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    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) +      
    "&pnum="+ convertSimple(rowNum) + "&entime=" + enteredInTime
                    + "&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());
        }

And my server-side PHP file is:

?php
$jobnum=$_GET['jobnum'];
//echo "jobnum = $jobnum <br />";
$pnum=$_GET['pnum'];
//echo "pnum = $pnum <br />";

$entime=$_GET['entime'];
//echo "entime = $entime <br />";

$extime=$_GET['extime'];
//echo "extime = $extime <br />";


$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 <br />";
?>

The logcat for the relevant section:

06-22 13:33:11.341: I/HTTP Post(27788): Execute Post sending
jobnum=189193&pnum=3&entime=9:00&extime=9:05 06-22 13:33:11.581:
I/HTTP Post(27788): Response from server = OK Code = 200

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). convertSimple() is a 2 liner that returns the String equivalent for an int primitive.

Thanks in advance for looking at this!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:48:48+00:00Added an answer on June 6, 2026 at 2:48 pm

    The reason you see the variables when you enter them in the browser is the difference between GET and POST. When you use the browser you are sending your variables in GET format.

    In your php code use:

    $_POST['varname'];
    

    Or you can use request to get POST and GET vars:

    $_REQUEST['varname'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the code snippet below, I am trying to persist two entities - Account
I'm trying to POST some multipart form data to my server using a Browser
Consider I have a table, like below, that I am trying to populate with
Below is a snippet of code i am trying to use to search an
I'm trying to write a vs code snippet that will take the selected and
The snippet of the PHP script below works for the most part... except for
In the code snippet below, from my jQuery setup, I need to check if
I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10
Please look at the below code snippet and let me know how the out
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.