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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:23:04+00:00 2026-06-10T10:23:04+00:00

I’m trying to use a web service to store/retrieve info from a remote SQL

  • 0

I’m trying to use a web service to store/retrieve info from a remote SQL database. For some reason empty strings are being inserted into the DB rather than the strings I want stored.

What I need is to store the strings deviceID & dateStamp if no entry in DB exists with deviceID.

DB table name is trials, and the columns are: _id | device_id | install_date

Note: Connects and interacts with database, just stores “” and “” instead of the strings.

Can someone please tell me why this is? This is my first time I’ve tried this kind of thing so having a lot of trouble and trying to modify snippets I found to my needs.

Here is my java code:

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings.Secure;
import android.widget.Toast;

public class LicenseCheck extends Activity 
{
    String deviceID="",dateStamp="";       
    byte[] data;    
    HttpPost httppost;    
    StringBuffer buffer;    
    HttpResponse response;    
    HttpClient httpclient;    
    InputStream inputStream;    
    List<NameValuePair> nameValuePairs;

    public void onCreate(Bundle savedInstanceState)    
    {        
        super.onCreate(savedInstanceState); 
        final String android_id = Secure.getString(getApplicationContext().getContentResolver(),Secure.ANDROID_ID);        
        deviceID = android_id; 
        Date now = new Date();
        dateStamp = String.valueOf(now);

        try 
        {                    
            httpclient = new DefaultHttpClient();                    
            httppost = new HttpPost("http://99.57.234.12/Main.php");                    
            // Add your data                    
            nameValuePairs = new ArrayList<NameValuePair>(2);                   
            nameValuePairs.add(new BasicNameValuePair("device_id", deviceID));                    
            nameValuePairs.add(new BasicNameValuePair("install_date", dateStamp));                    
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));                     
            // Execute HTTP Post Request                    
            response = httpclient.execute(httppost);                    
            inputStream = response.getEntity().getContent();                     
            data = new byte[256];                     
            buffer = new StringBuffer();                    
            int len = 0;                    
            while (-1 != (len = inputStream.read(data)) )                    
            {                        
                buffer.append(new String(data, 0, len));                    
            }                     
            inputStream.close();                
            } catch (Exception e) {                    
                Toast.makeText(LicenseCheck.this, "error"+e.toString(), Toast.LENGTH_LONG).show();                
            }                
            if(buffer.charAt(0)=='Y')                
            {                    
                Toast.makeText(LicenseCheck.this, "working: " + buffer.toString() + ".", Toast.LENGTH_LONG).show();

                Move_to_next();
                LicenseCheck.this.finish();
            } else {                    
                Toast.makeText(LicenseCheck.this, "Trial Started", Toast.LENGTH_LONG).show();
                Move_to_next();
                LicenseCheck.this.finish();
            }                    
        }        
    public void Move_to_next()        
    {         
        startActivity(new Intent(this, MainMenu.class));        
    }
}

Here is the PHP:

<?php 
    require_once('Connections.php'); 
    mysql_select_db($database_localhost,$localhost); 

    $device = $_POST['device_id'];
    $date = $_POST['install_date'];

    $query_search = "select * from trials where device_id = '".$device."'"; 
    $query_exec = mysql_query($query_search) or die(mysql_error()); 
    $rows = mysql_num_rows($query_exec);  



    if($rows --> 0) 
    { 
        echo "Y"; 
        $result = mysql_query("SELECT device_id,install_date FROM trials WHERE device_id = '".$device."'");
        if (!$result) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $row = mysql_fetch_row($result);

        echo $row[0]; // device_id
        echo $row[1]; // install_date
        } else {
        echo "N";
        mysql_query("INSERT INTO trials (device_id, install_date) VALUES ( '".$device."', '".$date."')") or die (mysql_error()); 
    }
?>
  • 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-10T10:23:05+00:00Added an answer on June 10, 2026 at 10:23 am

    You’re posting:

    nameValuePairs.add(new BasicNameValuePair("DeviceID", deviceID));
    nameValuePairs.add(new BasicNameValuePair("DateStamp", dateStamp));
    

    But you’re looking for:

    $device = $_POST['device_id'];
    $date = $_POST['install_date'];
    

    Your PHP is looking for variables in $_POST that haven’t been set.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a view passing on information from a database: def serve_article(request, id): served_article
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.