Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP - Undefined index??

  • 31-05-2007 11:13PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    I'm trying to check a session variable and if its not initailised then it will just show a login box but i get the below notice, any idea how to get around this??
    Notice: Undefined index: auth in C:\Apache\htdocs\bt\forum.php on line 48
    [PHP]try
    {
    if($_SESSION == 1207)
    {
    stats();
    }
    }
    catch(Exception $e)
    {
    echo'Welcome guest';
    }[/PHP]


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Your PHP warning level is set to "notice", i.e. 8.

    If you can't change the warning level, add an "isset" check to the code

    if ((isset($_SESSION["auth"])) && ($_SESSION["auth"]==1207)) {

    }

    The first part of the if will be evaluated first; if it's not set, it can't be set to 1207, so it'll still be false.

    L


Advertisement