Jump to content

$session error


ali_2kool2002

Recommended Posts

Hi can someone help me resolve this error it keeps sayin notice of undefined constant?  :'(


[quote]Notice: Use of undefined constant id - assumed 'id' in h:\Project\htdocs\fiinalyear\homePage.php on line 59[/quote]

and on line 59 i have  

[code]
  <?
if(isset($_SESSION[id])){echo"--------- <b>Welcome $_SESSION[id]</b>--------";}

?>

 

I do have a session_start() after the body of the html aswel

 

[code

<body>

<? session_start();?>

[/code]

Link to comment
https://forums.phpfreaks.com/topic/44379-session-error/
Share on other sites

It's a problem, but the notice you are getting is because you are referencing "id" without any single quotes. Normally that would mean it is a predefined constant, but since PHP is smart, it just throws a notice and converts it to 'id'. Change $_SESSION[id] to $_SESSION['id'] and put session_start at the very top of the code and you should be ok.

Link to comment
https://forums.phpfreaks.com/topic/44379-session-error/#findComment-215529
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.