elepil
asked on
Weird PHP error message
I am getting an error in php_error_log that says:
I have a login.php, and at the very top is:
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??
PHP Notice: Undefined variable: _SESSION in C:\xampp\htdocs\newdimension\public\login.php on line 3
I have a login.php, and at the very top is:
<?php
$pageTitle = "Login";
$errorMessage = $_SESSION['error'];
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Always check to make sure the variable is set first before using it:
if(isset($_SESSION['error'])){
$errorMessage = $_SESSION['error'];
}
ASKER
My original question was why PHP was somehow interpreting my $_SESSION as _SESSION. Your answer doesn't seem to be addressing that.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help!
ASKER
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?