Re: Someone please help me with this PHP script.

From: Date: Sun, 18 Dec 2005 16:26:13 +0000
Subject: Re: Someone please help me with this PHP script.
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-227613@lists.php.net to get a copy of this message
Okay.. I was just wondering; What's the difference between = and ==? Would it matter if I changed them? It seems as though if I put = instead of the =='s, it comes up ONLY page two no matter what $page equals, and if it's ='s instead of =='s, then it comes up with only page one no matter what $page equals. On 12/18/05, Zareef Ahmed <consultancy@indiaphp.com> wrote: > > > ----- Original Message ----- > From: "M. Sokolewicz" <tularis@php.net> > To: <budduh@gmail.com> > Cc: "PHP LIST" <php-general@lists.php.net> > Sent: Sunday, December 18, 2005 4:34 AM > Subject: Re: [PHP] Someone please help me with this PHP script. > > > > Aside from the 20 suggestions you've already got, let me add this one: > > elseif( ($page != "one") or ($page != "two") or ($page != NULL) ) { > > > > Echo > > "<html><head><title>Undefined!</title></head><body>page > > isn't > > defined correctly!</body></html>"; > > } > > > > is useless code. Why? > > $page = null; never happens (you made sure of that further up the page). > > $page = "one"; never happens (you already pulled that one out earlier). > > $page = "two"; never happens (you already pulled that one out earlier). > > > > Johnson, make a note of it. > > you can also read about "switch" statement. > > Zareef Ahmed > > > So... if *any* of those returns true you show an error... may I suggest > > just changing it to an else instead? a lot more logical(!). > > Besides that, were you to move this to its own if() you'd notice it > > would always display because if the page is "one" it *can not* be > > "two" > > or null, and will thus be displayed. Which means that you'd have an > > error which would always display... > > > > oh well, ignore my rant and first make sure to follow the suggestions > > provided by others > > > > - tul > > Wolf wrote: > > > What is it doing, or not doing? > > > > > > Try changing the <? to <?php and see if that works. > > > > > > Robert > > > > > > Erik Johnson wrote: > > > > > >>I do not know why this isn't working, but it would be very helpful if > > >>someone looked over it. > > >> > > >><? > > >>$defaultpage = > > >>"http://lom.game-host.org/uploads/erik/"; > > >> > > >>If($page == NULL) { > > >> $page = "one"; > > >>} > > >> > > >>if($page == "one") { > > >> Echo "<html><head><title>Page > > >> One</title></head><body>It > works!!<br><a > > >>href=\"" . $defaultpage . > "index.php?page=two\">Nice...</a></body></html>"; > > >>} > > >> > > >>elseif($page == "two") { > > >> Echo "<html><head><title>Page > > >> Two</title></head><body>This is page > " > . > > >>$page . " -- <a href=\"" . $defaultpage . "index.php > > >>?page=\">;D</a></body></html>"; > > >>} > > >> > > >>elseif( ($page != "one") or ($page != "two") or ($page != > > >>NULL) ) { > > >> Echo > > >> "<html><head><title>Undefined!</title></head><body>page > > >> isn't > > >>defined correctly!</body></html>"; > > >>} > > >> > > >>if($page == "") { > > >> Echo > > >> "<br><br><br><br><br><br><br><br><a > > >> href=" . $defaultpage .. > ">Main > > >>Page..</a>"; > > >>} > > >>?> > > >> > > >>Thank you, > > >> > > >>Erik Johnson > > >> > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > ==================================================== > PHP Expert Consultancy in Development http://www.indiaphp.com > Yahoo! : consultant_php MSN : consultancy@indiaphp.com > > > > > >

« previous php.general (#227613) next »