Adam
Adam

Reputation: 20882

PHP SESSION VAR Exists but PHP message: PHP Notice:

I'm getting this error:

[17-Oct-2014 08:46:12] WARNING: [pool blah.com] child 43657 said into stderr: 
"NOTICE: PHP message: PHP Notice:  Undefined index: database_geo in /var/blah/site_profile.class.php on line 124"

The error is for the following code and I've put a var_dump() in front of it with the session var:

print '<pre>';
var_dump($_SESSION['database_geo']);
print '</pre>';

    // GEO Distance between Members in KM or Miles
    if($this-true) {
        $sql='SELECT la,b FROM geoWorld WHERE pid=? LIMIT 1;';
        $pds=$database->pdo->prepare($sql); $pds->execute(array($_SESSION['database_geo'])); $row=$pds->fetch();
        $this->geoDistanceToMe = $location->geoDistanceBetweenMembers($this->profileLatitude,$this->profileLongitude,$row['latitude'],$row['longitude'],FALSE);
    }

The page displays fine but the error shows. I can see the variable "$_SESSION['database_geo']" exists as it display sin the var_dump().

Is there any reason why this message would appear of the var exist?

thankyou - confused...

Upvotes: 1

Views: 84

Answers (1)

Andrei Puf
Andrei Puf

Reputation: 81

Use session_start() before entering or getting something from $_SESSION. See this link http://php.net/manual/ro/function.session-start.php

Upvotes: 3

Related Questions