[thelist] php - displaying default data

Manuel González Noriega manuel at simplelogica.net
Wed Jan 28 17:07:38 CST 2004

El mié, 28-01-2004 a las 23:23, Travis escribió:

First, this is not an error but a notice, with the "error reporting"
settings in php.ini you can switch off the error messages for this kind
of issues 

> Here are the errors I'm gettting:
>   Notice: Undefined index: month
>   Notice: Undefined index: year

>   Once you choose a link, it works fine. Here's my php code that works fine:
> <?
>     $monthTemp = $_GET["month"];
>     $yearTemp = $_GET["year"];
> ?>

Ok, the first time you enter the page $_GET[] is empty and thus the
notices. Let's get down to business


// Check than both variables exist
if (isset($_GET['month']) && isset($_GET['year'])) {

  // If so, assign
    $monthTemp = $_GET["month"];
    $yearTemp = $_GET["year"];
    include( "blog/$yearTemp/$monthTemp.php" );


else {
// If they ain't set, proceed as desired


Note you could also use if (!empty($_GET))


HTH :)
Manuel González Noriega
Simplelógica, construcción web  
    URL: http://simplelogica.net
    EMAIL: simplelogica at simplelogica.net
    TELEFONO: (+34) 985 22 12 65
Logicola es el weblog de Simplelógica http://simplelogica.net/logicola/

More information about the thelist mailing list