Link to home
Start Free TrialLog in
Avatar of elepil
elepil

asked on

Weird PHP error message

I am getting an error in php_error_log that says:

PHP Notice:  Undefined variable: _SESSION in C:\xampp\htdocs\newdimension\public\login.php on line 3

Open in new window


I have a login.php, and at the very top is:

<?php
$pageTitle = "Login";
$errorMessage = $_SESSION['error'];

Open in new window


PHP thinks I am spelling $_SESSION as _SESSION, what the hell??!

I've looked this over and over and can't figure out why PHP would think this. Can anyone please explain this to me??
SOLUTION
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil
elepil

ASKER

Loganathan,

Okay, I can see that error I made. But even then, shouldn't the result of my error be a null $errorMessage? Why would PHP flag it as an undefined variable?
Always check to make sure the variable is set first before using it:

if(isset($_SESSION['error'])){
    $errorMessage = $_SESSION['error'];
}

Open in new window

Avatar of elepil

ASKER

My original question was why PHP was somehow interpreting my $_SESSION as _SESSION. Your answer doesn't seem to be addressing that.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil

ASKER

Marco,

But what causes this to happen? I want to know so I don't repeat this. This kind of error message is really annoying.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil

ASKER

Thanks for the help!