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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:07:11+00:00 2026-05-31T13:07:11+00:00

I have some code below which will not run due to me not being

  • 0

I have some code below which will not run due to me not being able to know how to call a function that’s within the same class as another function. I’ve already tried using $this but it gives me a PHP error Using $this when not in object context...Line 25. I have no clue how to fix this and I’m hoping someone else can give me some tips on what to do. My code is below, thanks 🙂

class SESSION {
    function start() {
        session_start();
    }
    function check() {
        if ($_SESSION["username"]) {
            return $_SESSION["username"];
        } else {
            return "nli"; //Not logged in :(
        }
    }
    function set_session($username) {
        $_SESSION["username"] = $username;
    }
    function login($username, $password) {
        $database = DB::connect();
        $passwordsha = sha1($password);
        $query = "";
        $res = $database->query($query);
        $num = $res->num_rows;
        if ($num == 0) {
            header("Location: login.php?e=1");
        } elseif ($num == 1) {
            $this->set_session($username);
            header("Location: admin.php");
        } else {
            header("Location: login.php?e=2");
        }
    }
}
  • 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-31T13:07:11+00:00Added an answer on May 31, 2026 at 1:07 pm

    And no, I’m not creating the object

    This is why the call to $this->set_session($username); is failing, if you want to follow the same code pattern you have in place you can do this:

    if ($num == 0) {
        header("Location: login.php?e=1");
    } elseif ($num == 1) {
        self::set_session($username);
        header("Location: admin.php");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: original question below, but I revise it now that I have some code
I have some code as shown below: - (IBAction)startButtonPressed:(id)sender { statusText.text = @Processing...; //here
I have some really funky code. As you can see from the code below
UPDATE - I have fixed some mistakes in the code below and the images
I have some problem with my cfml website. I have used the below code
I'm wondering about the .childNodes property, I have the code below, and for some
I have some code which populates a hashtable with a question as the key
I have some code using a System.Transactions.TransactionScope , that creating a new instance of
I have some iPhone SDK 4.0 code which initializes an NSOperationQueue and then adds
I have been writing some code that creates a generic blog. Its features are

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.