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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:47:53+00:00 2026-06-07T03:47:53+00:00

This question is related to this topic. I changed the syntax to one that

  • 0

This question is related to this topic. I changed the syntax to one that was suggested so my code now looks like this:

method in class:

private $password;
private $user_id;
private $img_thumb;

public function getUserInfo(){
            $stmt = $this->dbh->prepare("SELECT user_id FROM oopforum_users WHERE username = ?");
            $stmt->bindParam(1, $this->post_data['username']);
            $stmt->execute();

            while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {

                $password = $row['password'];
                $user_id = $row['user_id'];
                $img_thumb = $row['thumbnail'];
            }
            return array(
                'password' => $this->password,
                'id' => $this->user_id,
                'thumb' => $this->img_thumb
                );

        }

Calling program:

session_start();
require_once('init.php');

$username = trim($_POST['username']);
// create a new object
$login = new Auth($_POST, $dbh);

    if($login->validateLogin()){

        $_SESSION['loggedin'] = true;
        $list = $login->getUserInfo();


        $_SESSION['password'] = $list['password'];
        $_SESSION['id'] = $list['id'];
        $_SESSION['thumb'] = $list['img_thumb'];
}

None of the variables appear to be passed back to the calling program, have I missed something in the class where I need to explicitly state that they can be passed back?

I print_r()‘d the $list array and it doesn’t contain the three variables.

The three entries do exist in the database.

What am I doing wrong in getting the retrieved database entries back in the array in the calling program?

  • 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-07T03:47:55+00:00Added an answer on June 7, 2026 at 3:47 am

    On your while loop, assign the variables to current object:

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
      $this->password  = $row['password'];
      $this->user_id   = $row['user_id'];
      $this->img_thumb = $row['thumbnail'];
    }
    

    Update: And you missed some fields in your SQL:

    SELECT user_id, password, img_thumb FROM oopforum_users WHERE username = ?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: This question is only loosely related to tinyxml, however including details like that
My question is related to this topic How to copy and paste code without
The title is my question. I already found a topic related to this here
This question is related to the one I asked here . I'm trying to
This is a NEW question and it is highly related to this topic: How
Load when the browser is open Thats my previous question related to this topic.
Now I know there is some related questions on this topic but this is
I posted a question related to this topic earlier, but I'm having trouble figuring
I read all topics related to this question in stackoverflow and whole internet and
All my questions in this topic related to asp.net 2.0 While working on some

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.