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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:50:44+00:00 2026-05-22T17:50:44+00:00

I have been recently learning some OOP PHP and seem to have run into

  • 0

I have been recently learning some OOP PHP and seem to have run into a problem when using the mysql_fetch_object(), receiving the error

Notice: Undefined property:
stdClass::$FirstName in
C:\xampp\htdocs\includes\login.php on
line 10

Here is the code I am using:

class User
{
    public function CheckLogin()
    {
        $conn = new db();
        $_email = mysql_escape_string($this -> Email);
        $_password = mysql_escape_string($this -> Password);

        $data = mysql_query("SELECT Email, Password FROM users WHERE Email = 'test@test.com AND Password = 'test' AND Enabled = 1") or die(mysql_error());

        return mysql_fetch_object($data);
    }
}

And I am calling this function as follows:

$u = new User();
$user = $u -> CheckLogin();
echo $user -> FirstName;

I’m pretty stumped by what I’m doing wrong, would anyone be able to point me in the right direction or give a possible fix?

  • 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-22T17:50:45+00:00Added an answer on May 22, 2026 at 5:50 pm

    You are fetching just two columns with your query: Email and Password. So all the other fields in your table, including the field FirstName, will not be fetched and is not available in the object your returning from the function.

    Try the query:

    SELECT FirstName, Email, Password FROM users WHERE Email = 'test@test.com AND Password = 'test' AND Enabled = 1
    

    This will also fetch the FirstName property, or use * to select all columns so you can use any field in your fetched object. Good luck!

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

Sidebar

Related Questions

I've been a web developer for some time now, and have recently started learning
I come from classes object orientation languages and recently I have been learning those
I have been recently (and repeatedly) asked by customers about MIPS needed to run
I have recently been doing a bit of investigation into the different types of
I have recently been working with Python using Komodo Edit and other simpler editors
I have recently been learning about doctypes, and was I wondering what the differences
I have recently been learning F# and functional programming. One application I have found
I'm relatively new to java (specifically swing) and have recently been making some fairly
I have recently been getting my feet wet in MongoDB using Mongoid w/ Rails
Recently I have been learning about WMI and WQL. I found out the list

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.