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 7822123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:50:06+00:00 2026-06-02T07:50:06+00:00

So I am writing an Android application, and part of it is supposed to

  • 0

So I am writing an Android application, and part of it is supposed to use GPS to acquire longitude/latitude. And those values are supposed to post to a PHP server I also have running. The function I have posting is as follows:

public void doAll() {

Double locLat, locLon;
    try {
    locLat = locManager.getLastKnownLocation(locProvider).getLatitude();
    locLon = locManager.getLastKnownLocation(locProvider).getLongitude();
    } catch (NullPointerException e) {
    locLat = -1.0;
    locLon = -1.0;
    }
try {

    HttpClient client = new DefaultHttpClient();
    //we put all the parameters in the URL itself
    HttpPost request = new HttpPost("http://fatalatour.com/database.php?function=get_all&latitude="+Double.toString(locLat)+"&longitude="+Double.toString(locLon));

    ResponseHandler <String> responseHandler = new BasicResponseHandler();

   //List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
   //nameValuePairs.add(new BasicNameValuePair("latitude", Double.toString(locLat)));
   //nameValuePairs.add(new BasicNameValuePair("longitude", Double.toString(locLon)));
   //request.setEntity(new UrlEncodedFormEntity(nameValuePairs));

   String response = client.execute(request, responseHandler);
   Log.i("HOMI_RESPONSE", response.toString());

}

There is other code withing that but I believe that is all that actually affects the posting of locLat and locLon.

For the server end I have:

function get_all() {
            $lat = trim($_GET['latitude']);
            $lon = trim($_GET['longitude']);
            // DEBUG
            $f = fopen('debug.log', 'a');
            fprintf($f, 'get_all: '.print_r($_REQUEST, true)."\n");
            $result = mysql_query("SELECT * FROM homi_table");

            $num = 0; //# of homicides

            while ($row = mysql_fetch_assoc($result)) {
                    $d = distance($row['latitude'], $row['longitude'], $lat, $lon, "K");
                    if ($d < 100) { //number to change for distance filter
                            $num += 1;
        echo "fatality:".$row['slug']."~".strtoupper($row['name']).", Age ".$row['age']."\n".$row['date']."\nhttp://projects.latimes.com/homicide/post/".$row['slug']."~".$row['latitude']."~".$row['longitude'];


                            // GH: limiting the number of results to 100
                            if ($num == 100) {
                                    break;
                            }
                    }
            };
            echo $num;
            fprintf($f, "get_all: returning: ".$num."\n");
    }

Right now the issue seems to be the handling of $lat and $lon. When i hard code in a static number for each of those in the PHP the app works, yet when I leave it variable (as it should be), it fails. Any help would be greatly appreciated!

  • 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-02T07:50:08+00:00Added an answer on June 2, 2026 at 7:50 am

    In Android application you are using POST request, in PHP you read GET parameters. Nothing else come to my mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a little application in android which would have a server part
I am writing an android application, which communicates with server when the user logs
I´m writing an android application that receives gps data from a MySQL database, such
When writing an Android application, what is the preferred method to store constant values,
I am currently writing part of an Android application to upload a video to
I'm writing an android application, which user can download some image files from server.
I'm writing an Android application, a dictionary just for fun. I've decided to use
I am writing an android application which uses a REST-based API on the server.
I am writing an Android application which has to connect to a server through
I'm writing an android application that will rely heavily on a tomcat server. Before

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.