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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:19:41+00:00 2026-05-27T06:19:41+00:00

Hi I am looking to receive POST data from an Android app and put

  • 0

Hi I am looking to receive POST data from an Android app and put it into a MYSQL server using PHP to script.

I am getting no results and I have gone through various examples and tutorials.

NEW WORKING PHP SCRIPT

<?php
$needsarray = str_split('$_POST[needs]');
$needs1 = 0;
$needs2 = 0;
$needs3 = 0;
$needs4 = 0;

if ($needsarray[0] =="1"){
 $needs1 = 1;
}
if ($needsarray[1] =="1"){
 $needs2 = 1;
}
if ($needsarray[2] =="1"){
 $needs3 = 1;
}
if ($needsarray[3] =="1"){
 $needs4 = 1;
}

$con = mysql_connect("localhost","haitidis_test","S3an");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

 mysql_select_db("haitidis_AppData", $con);

$sql="INSERT INTO Extensive (disaster, people, lat, lng, phone, needs1, needs2, needs3,    needs4) 
VALUES ('$_POST[disaster]', '$_POST[people]', '$_POST[latitude]', '$_POST[longtitude]',     '$_POST[userphone]', $needs1, $needs2, $needs3, $needs4)";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";
mysql_close($con);
?>
  • 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-27T06:19:42+00:00Added an answer on May 27, 2026 at 6:19 am

    Nothing really wrong with your code. I tested the Java code in my eclipse and the PHP looks fine. For starters try seeing if your phone code and php code actually talk to each other.

    Add a var_dump($_POST) to the end PHP:

    Change your code a little bit to this:

     ResponseHandler<String> responseHandler = new BasicResponseHandler();
     String response = httpclient.execute(httppost, responseHandler);
    
     System.out.println(response);
    

    Print the results. If your post values are printed, then then there’s nothing wrong on the phone side. Maybe something is wrong in the PHP script although it’s not obvious to me right now. If something went wrong with your connection, the

    ‘Could not connect’

    will be printed.

    UPDATE: Since you said, nothing is being inserted into the database. Try doing this:

    $result = mysql_query('PUT INSERT STATEMENT HERE');
    var_dump($result);
    

    If the result is false var dump the sql error:

    var_dump(mysql_error());
    

    UPDATE:

    Warning: mysql_query() [function.mysql-query]: Access denied for user
    ‘haitidis’@’localhost’ (using password: NO) in
    /home/haitidis/public_html/extensive.php on line 42

    Are you sure you are using the right password — “S3an” ?

    UPDATE:

    You should put the following lines of code before closing your connection:

    $result = mysql_query("INSERT INTO Extensive (disaster, people, lat, lng, phone, 
         needs1, needs2, needs3, needs4) VALUES ($disaster, $people, $lat, $long, $phone,     
        $needs1, $needs2, $needs3, $needs4)");
    
    mysql_close($con);
    

    Check your db now if the rows are being inserted.

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

Sidebar

Related Questions

I'm looking to implement a post-receive script that would deploy my newly pushed data
I am looking for suggestions on the best way to send/receive data from a
I am looking for several SMS api. Basically to receive sms messages from mobile
I'm looking for an example how to emulate XMLHttpRequest client using PHP. In other
I'm looking to upload an mp3 file from my iPhone app to a given
I'm looking at the source code for a server using SocketAsyncEventArgs, and I'm trying
I'me looking for a function that would receive a time and would round it
I am looking for a way to send and receive keyboard information regardless of
I have an existing PHP/MySQL website that relies hugely on form POSTs for things
I use $_POST to read data sent through HTML forms to the server, narrowing

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.