Re: Trouble with switch statements

From: Date: Sun, 17 Nov 2002 05:30:50 +0000
Subject: Re: Trouble with switch statements
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124767@lists.php.net to get a copy of this message
This appears to be a register globals problem.... replace "switch($select)" with "switch($_GET['select'])". For information on register globals and why it has been turned off in later releases see this pagee: http://www.php.net/manual/en/security.registerglobals.php There is nothing syntactically wrong with the switch statment you are just refering to an non-existant variable... I imaginge this came from an outdated book or tutorial. -- JJ Harrison lizner2002@yahoo.com.au "Edward Kehoe" <emkehoe@learn.senecac.on.ca> wrote in message news:20021025174451.82626.qmail@pb1.pair.com... > Ok...I just recently installed Apache1 and PHP 4.2.3 on my computer and I've > configured everything. However, I can't seem to get my switch statements to > accept variable values from the address bar. So if I type in: > > http://www.my-site.com/index.php?select=1 > > It displays the text in the default part of the switch statement. I also > seem to get the following error message every time: > > Notice: Undefined variable: select in c:\apache\apache\htdocs\index.php on > line 51 > > Here's the code for my switch statement as well: > > switch($select) > { > case 1: print "About Stuff Goes Here."; > break; > case 2: print "Music Goes Here."; > break; > default:print "Testing..."; > break; > } > > >

« previous php.general (#124767) next »