-1

I got this error and cant fix it help me please

Message: Trying to get property of non-object

Filename: controllers/auth.php

Line Number: 20

and this is my code: The line 20 starts at if ($user->mail){

if ($user->mail) {
            $this->session->set_flashdata("Success","You Are now logged in");

            $_SESSION['user_logged'] = TRUE;
            $_SESSION['username']=$user->username;
        }
        else {
            $this->session->set_flashdata("error", "No Account exists in Database");
        }
    }
Dave
  • 172
  • 1
  • 3
  • 11

2 Answers2

1

The most likely cause of the error message is that $user is null.

netom
  • 3,322
  • 2
  • 21
  • 21
0

Well as the error is self explanatory, you are using:

$user->mail
$user->username

But according to the error $user is not an object and as such you can not get property of non-object. So try to figure out what exactly are you doing with $user, returning an object or an array.

Just_Do_It
  • 821
  • 7
  • 20