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

  • Home
  • SEARCH
  • 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 5958319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:31:34+00:00 2026-05-22T18:31:34+00:00

Ive been trying to send gps data from my android app to a mysql

  • 0

Ive been trying to send gps data from my android app to a mysql database using php but Im not sure if everything is set up right because I can see through the logcat that the data is being sent from android but its just not getting sucked up by the database.

Aside from some recommendations does any body have any tutorials that would show specifically the php to server code.

Also is it possible to just send the data straight to the database without something like php? I dont think so but I had to ask.

here is the php that I am using with the addresses and stuff taken out for obvious reasons.

<html>
<head>
<title>Send and Rec data to Android Device</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


</head>


<body>


<?php
//include("dbinfo.php");



///the stuff pointing to my db has been removed for obvious ///reasons ;)


mysql_connect($hostname,$username,$password) or die ("<html><script           
language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-                
1)     </script></html>");


mysql_select_db($dbname);


// variables coming from Android  app on phone
$id = $_POST["id"];


$lat = $_POST["lat"]; // If data is in DB line 1 (public key), but the publicly displayed PHP is     
not showing data then we know that we aren't really talking to line 1

$lng = $_POST["lng"];


$alt = $_POST["alt"];


$spd = $_POST["spd"];


$acc = $_POST["acc"];


$last_gps = $_POST["lastgps"];


//filler will contain reference to graphic or audio upload directory
$filler = $_POST["filler"];


$lastid = mysql_query("select MAX(id) as maxid from samplemarks");
$row = mysql_fetch_array($lastid);


$nextid = $row[maxid] + 1;


echo "Inserting at next id = ".$nextid."<br />";


if ($lat == "") 

{
 echo "Invalid entry, latitude cannot be blank";

}

  else {
  $query2 = mysql_query("INSERT INTO samplemarks VALUES($nextid,'$lat',     
  $lng,'$alt','$spd','$acc','$last_gps','$filler')");

  mysql_query($query2);


mysql_close();


}
?>


</body>


</html>
  • 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-05-22T18:31:35+00:00Added an answer on May 22, 2026 at 6:31 pm

    Your mysql_query is missing the connection parameter. When you do the connect, store it in a variable eg

    $conn =  mysql_connect($hostname,$username,$password) or die('Blah');
    
    if ($conn) {
    
        mysql_select_db("mydatabasename", $conn);
    
       // extract your data
       if (isset($_POST["id"]) && isset($_POST['lat']) && isset($_POST['lng']) {
    
               $id = $_POST['id'];
               $lat = $_POST['lat'];
               $lng = $_POST['lng'];
    
               // add the rest of the POST fields so the query below works
               // unless you need a specific $nextid make the field auto increment in the
               // database and user '' instead of $nextid.  
    
       $query2 = "INSERT INTO samplemarks VALUES($nextid,'$lat',     
         '$lng','$alt','$spd','$acc','$last_gps','$filler')";
    
        if (mysql_query($query2, $conn))
            echo "data inserted';
        else
            echo "Oh dear ".  mysql_error() ;
    
    
           // etc
      }  // end the isset tests
    }
    

    Also $lng isn’t quoted in your code.

    I realise that you are sending data from your android application to your php/db server but you should always sanity check the data from the post, otherwise you’re making it easy for someone to use sql injection attacks to compromise your database. Think about protecting your php with ssl and username/password

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

Sidebar

Related Questions

i've been trying to send data to the following form from my view. i
I've been trying to send an email from my magento module but for some
Ive been trying to display formatted content blocks from a xml file with no
I've been trying to use MFMailComposer to send a text file with encrypted data
I've been trying to send packets to a tap interface using python. I'm monitoring
I've been trying to send a packet from a client to a server via
I've been trying to send a JSON string to PHP server like this: $.ajax({
I'm trying to send some data from a C++ server to a C# client.
I've been trying to figure out how to send JMS messages from Ruby. I've
I've been trying to connect to a bluetooth service using j2me but I am

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.