solved, thank's

Marco Branco

2008/7/23 James Keeline <[EMAIL PROTECTED]>:

>   --- Marco Branco <[EMAIL PROTECTED]<marcobranco1975%40gmail.com>>
> wrote:
>
> > i have this link in a web page (www.mydomain.com/index.php?id=2).
> >
> > and in the index.php i have
> >
> > <?php
> > (...)
> > switch ($id)
> > {
> > case 1: echo('um - 1'); break;
> > case 2: echo('dois - 2'); break;
> > case 3: echo('tres - 3'); break;
> > default: echo('defaulf - any');
> > }
> > (...)
> > ?>
> >
> > I alwys get the last line of the switch: *default - any*
> >
> > Why?
>
> It appears that you are assuming that $id will contain the GET variable
> "id"
> automatically. This was true in old installations of PHP but not for the
> past
> several years. A feature known as "register_globals" is and should be
> "off."
>
> To resolve this, before you use $id set it like this:
>
> $id = $_GET['id'];
>
> Otherwise, it will always be zero and lead to your default case in the
> switch()
> statement.
>
> James
>
>  
>



-- 
Marco Branco


[Non-text portions of this message have been removed]

Reply via email to