0

Can someone help me with a simple fix about my code of an simple function? thanks before!! Im getting that error into my logs: PHP Notice: Undefined index: ID

    function hasMembership($odb) {
        $SQL = $odb -> prepare("SELECT `expire` FROM `users` WHERE `ID` = :id");
        $SQL -> execute(array(':id' => $_SESSION['ID']));
        $expire = $SQL -> fetchColumn(0);
        if (time() < $expire)
        {
            return true;
        }
        else
        {
            $SQLupdate = $odb -> prepare("UPDATE `users` SET `membership` = 0 WHERE `ID` = :id");
            $SQLupdate -> execute(array(':id' => $_SESSION['ID']));
            return false;
        }
    }
OpSec
  • 1
  • 1
    $_SESSION['ID']; isn't set. Try `var_dump($_SESSION);` to see what's in the session. Please can you add the code that shows it being set? – divil Feb 03 '20 at 21:21
  • @divil very thanks my friend it seems fixed!! – OpSec Feb 03 '20 at 21:25
  • While the syntax allows it, the arrow operator should not have spaces around it. `$odb->prepare(...)` is the conventional style. – tadman Feb 04 '20 at 00:05

0 Answers0