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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:51:17+00:00 2026-06-08T02:51:17+00:00

Im getting a null point exception when i runs this code. what i tried

  • 0

Im getting a null point exception when i runs this code.

what i tried to do is… get the useremail from the application to the string uemail and tried to fetch the friends who are friends with uemail.

activity

public class MainActivity extends Activity {
    protected static final String TAG_Name = null;
    int a;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        a = 2;
        Button ref = (Button)findViewById(R.id.button1);

        ref.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

                InputStream is = null;
                String result = "";

                ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

                String uemail = String.valueOf(a);
                nameValuePairs.add(new BasicNameValuePair("place_id", uemail));
                try {
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost httppost = new HttpPost(
                            "http://www.hopscriber.com/test.php");
                    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());
                }
                // convert response to stringtry
                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 {
                    ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

                    JSONArray jsonArray = new JSONArray(result);

                    if (jsonArray != null) {
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject object = (JSONObject) jsonArray.get(i);

                            HashMap<String, String> map = new HashMap<String, String>();

                            map.put(TAG_Name, object.getString("place_id"));

                            contactList.add(map);

                        }
                    }
                    TextView z = (TextView)findViewById(R.id.textView1);

                    z.setText(TAG_Name);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

php

<?php
include "db_config.php";

$q=mysql_query("SELECT 'name' FROM places WHERE place_id='".$_REQUEST['place_id']."'");

while($e=mysql_fetch_assoc($q))
        $output[]=$e;

print(json_encode($output));

mysql_close();
?>

i seems can’t find the answer…. please help me out.. it tigers null

  • 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-08T02:51:20+00:00Added an answer on June 8, 2026 at 2:51 am

    I noticed an issue with the mysql_query line and where the following " WHERE uname='".$_REQUEST['uemail']."'"); not being escaped properly on WHERE clause.

    The correct PHP is below.

     <?php
     $sql=mysql_query("SELECT`uname`,`place`,`time` FROM `check_in` 
     WHERE uname='".$_REQUEST['uemail']."'");
     while($row=mysql_fetch_assoc($sql)) $output[]=$row;
     print(json_encode($output));
     mysql_close();
     ?>
    

    Your java looks fine as long as you’re never invoking tryme() (say in a main method without defining userName prior).

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

Sidebar

Related Questions

i'm getting a weird null pointer exception in the last line of this code:
I'm getting a null pointer exception when I do this: private String[] foo; private
I am getting null-exception throw error in the following code. What can be the
I am getting a Value cannot be null error from the code below: @Html.Label(material.ExtendedGroup)
IN JAVA CODE IN JSP as below i m getting null value for fieldnoOfRecords.
Hi i am reading inbox using service but i m getting null pointer exception
I keep getting a null exception at the ; below. The ApiUsername & ApiPassword
I am getting a null pointer exception report in the android developer console. I
I'm getting an exception in my C#/.NET application that reads: 'CommandCoverter' is unable to
after upgrading from grails 1.3.7 to 2.0.1 i'm getting follwong strange exception when validating

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.