Page 1 of 1

Undefined variable: _SESSION

PostPosted: 18. August 2011 11:09
by FvR64
HI, I receive this note on localhost:

Notice: Undefined variable: _SESSION in C:\xampp\htdocs\villacare\shared\inc\init.inc.php on line 26

When entering the file I read this, where line 26 is : $db = $_SESSION['db'];

$default_delay = 3;
$page_size = 8;

$db = $_SESSION['db'];

$uk = false;
$nl = false;
$fr = false;
$es = false;
$de = false;

Presumebly the original script was made with an a older PHP version and seems not to be supported by the newer versions. Also is it on a localhost as we did not get it working.

Anyone a idea?

Re: Undefined variable: _SESSION

PostPosted: 18. August 2011 15:17
by WilliL
error_reporting is changed in newer xampp packages (php.ini).

I would keep this and change code
Code: Select all
if ( !isset($_SESSION['db'])) {
       $db = ""; // or "dummy"
    } else {
        $db = $_SESSION['db'];     
}

Re: Undefined variable: _SESSION

PostPosted: 18. August 2011 18:59
by Altrea
do you have a
Code: Select all
session_start();

line at the beginning of your script?

Re: Undefined variable: _SESSION

PostPosted: 19. August 2011 08:52
by FvR64
Thanks WilliL, I made the changes and I think it works, I did not receive the note again :)

Thanks Altrea, I tried this before an got another note as it was already written in another script which is part of the whole.

For now I have it working on localhost, now have to get it up end running on the web

Thanks again