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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:04:23+00:00 2026-05-23T16:04:23+00:00

My PHP file: <?php include(ConnectDatabase.php); $Username = mysql_real_escape_string($_POST[‘Username’]); $Password = mysql_real_escape_string($_POST[‘Password’]); $q = mysql_query(SELECT

  • 0

My PHP file:

<?php
include("ConnectDatabase.php");

$Username = mysql_real_escape_string($_POST['Username']);
$Password = mysql_real_escape_string($_POST['Password']);

$q = mysql_query("SELECT Username, Password FROM Users
                where Username = '".$Username."' and
                Password = '".$Password."'", $con);

if(mysql_num_rows($q) > 0){
    $row = mysql_fetch_assoc($q);
    print json_encode($row);


}else{
    print "0";
}


?>

I tried to parse that by the following to get a value,but it got null values both userJson and passJson:

public void parseJson(String result){

        try{
            JSONArray jArray = new JSONArray(result);
            for(int i=0;i<jArray.length();i++){
                 userJson = jArray.getJSONObject(i).getString("Username").toString();
                 passJson = jArray.getJSONObject(i).getString("Password").toString();   
            }
        }catch(JSONException e){
            Log.e("log_tag", "Error parsing data "+e.toString());
        }

Anyone can see my mistake ? Thank you

PS This is my older post that related to this post.

  • 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-23T16:04:23+00:00Added an answer on May 23, 2026 at 4:04 pm

    I would think they end up null cuz the first line doesn’t work. It’s not a JSONArray as you have generated.

       try {
          JSONObject root = new JSONObject(result);
          username = root.getString("Username");
          password = root.getString("Password");
       } catch (JSONException e) {
          Log.e("log_tag", "Error parsing data "+e.toString());
       }
    

    something like that.

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

Sidebar

Related Questions

I have this code which will include template.php file from inside each of these
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
Is there any way to include php file using require and calling a php
I am trying to include a .js file into a php file. My folder
I want to include the last 2 files in my php file based on
When I try to include a file using include_once in php which shows warning
I have 2 files namely: uploading.php emaillinks.php both include a file inc.php which has
I'm including a file init.php which defines path constants. So if I include init.php
This question is about the PHP parsing engine. When I include a file multiple
I'm using PHP include to include a PHP file that has HTML in it.

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.