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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:36:29+00:00 2026-05-31T10:36:29+00:00

When I execute these two codes, this error in the catLog appears: 03-18 01:05:16.602:

  • 0

When I execute these two codes, this error in the catLog appears:

03-18 01:05:16.602: E/log_tag(788): Error parsing data
org.json.JSONException: End of input at character 0 of

and in PHP I get this error:

[18-Mar-2012 00:03:54 UTC] PHP Parse error: syntax error, unexpected
T_STRING in /home/cyberite/public_html/khacheb/sig1.php on line 11

The php code:

<?php
  /**
   * Database config variables
   */
  $username = $_POST['username'];  
  $password = $_POST['password']; 

  mysql_connect("localhost","cyberite","WAJDI@NASRAOUI@");
  mysql_select_db("cyberite_khacheb");

  $query = mysql_query(“SELECT cin,accountNb,username , password FROM users WHERE    username = ‘$username’ AND password = ‘$password’”);  
  $result = mysql_query($query) or die(“Unable to verify user because : ” . mysql_error());
  while($row=mysql_fetch_assoc($query))
    $output[]=$row;
  print(json_encode($output));
  mysql_close();
?>

Here in the Android code:

package com.pfe.pfe;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import org.apache.http.HttpEntity;
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 org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class signin1 extends Activity {

  public static final String strURL = "http://cyberi-tech.com/khacheb/sig1.php";

  StringBuilder sb=null;

  TextView  inlog;
  TextView inpass;
  Button log;
  Button cancel;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.signin);

    inlog = (TextView)findViewById(R.id.inputUsername);
    inpass = (TextView)findViewById(R.id.inputPassword);
    log = (Button)findViewById(R.id.Login);
    cancel = (Button)findViewById(R.id.sigCancel);

    log.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        InputStream is = null;
        String result = "";

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("username", inlog.getText().toString()));
        nameValuePairs.add(new BasicNameValuePair("password", inpass.getText().toString()));

        try{
          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new HttpPost(strURL);
          httppost.setEntity(new  UrlEncodedFormEntity(nameValuePairs));
          HttpResponse response = httpclient.execute(httppost);
          HttpEntity entity = response.getEntity();
          is = entity.getContent();
        }
        catch(Exception e){
          Log.e("log_tag", "Error in http connection " + e.toString());
        }

        // Convertion de la requête en string
        try{
          BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
          StringBuilder sb = new StringBuilder();
          String line = null;
          while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
          }
          is.close();
          result=sb.toString();
        }
        catch(Exception e){
          Log.e("log_tag", "Error converting result " + e.toString());
        }

        try{
          JSONArray jArray = new JSONArray(result);
          for(int i=0;i<jArray.length();i++){
            JSONObject json_data = jArray.getJSONObject(i);
            Log.i("log_tag","cin: "+json_data.getInt("cin")+
              ", accountNb: "+json_data.getString("accountNb")+
              ", username: "+json_data.getString("username")+
              ", password: "+json_data.getString("password")
            );
          }
        }
        catch(JSONException e){         
          Log.e("log_tag", "Error parsing data " + e.toString());
        }       
      }
    });

    cancel.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        finish();   
      }
    });

  }
}
  • 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-31T10:36:31+00:00Added an answer on May 31, 2026 at 10:36 am

    Make sure that u get $_POST data. And always filter data before using it in sql query for security issue.

    <?php
    /**
    * Database config variables
    */
    $username = isset($_POST['username']) ? $_POST['username'] : '';  
    $password = isset($_POST['password']) ? $_POST['password'] : ''; 
    
    if(strlen($username) && strlen($password)) {
    
    mysql_connect("localhost","cyberite","WAJDI@NASRAOUI@");
    mysql_select_db("cyberite_khacheb");
    
    $username = mysql_real_escape($username);
     $password = mysql_real_escape($password);
    
    $query = mysql_query(“SELECT cin,accountNb,username , password FROM users WHERE    username = ‘$username’ AND password = ‘$password’”);  
    $result = mysql_query($query) or die(“Unable to verify user because : ” . mysql_error());
    while($row=mysql_fetch_assoc($query)) {
      $output[]=$row;
    }
    print(json_encode($output));
    mysql_close();
    }
    } //end of if
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I assume this is pretty easy so here goes; I'm trying to execute these
I have the following code but I get an error on this line userSpinner.setAdapter(adapter);
hey there guys and girls i have this code that saves json as a
I have an Entity Data Model with two entities in it Roles and Users.
I have std::list<Info> infoList in my application that is shared between two threads. These
I have two stored procedures that I want execute wrapped in a transaction. For
I keep getting the error Stream was not writable whenever I try to execute
Is there a way to execute a full ASPX source file where the page
Is there a way to execute SQL custom functions with Enterpise Library? I've tried
Is there a way to execute a query(containing built in DB function) using PreparedStatement?

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.