Re: Newbie - Undefined Index Variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 7, 2008 at 2:59 PM, revDAVE <Cool@xxxxxxxxxxxxxxxx> wrote:
> I have this:
>
>  <?php if (trim($_SESSION['nowtoctype']) == 'thistype')
>
>  {print '<a href="page1.php">page1</a>';}else{print '<a href="
>  page2.php">page2</a>';} ?>
>
>  I will get the error:
>
>  Notice: Undefined index: nowtoctype in ...

    Check out isset(): http://php.net/isset

<?php
    if(isset($_SESSION['nowtoctype']) && trim($_SESSION['nowtoctype'])
== 'thistype') {
        echo "<a href=\"page1.php\">Page 1</a>\n";
    } else {
        echo "<a href=\"page2.php\">Page 2</a>\n";
    }
?>

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux