Jump to content


Photo

default under switch question.


  • Please log in to reply
No replies to this topic

#1 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 22 March 2006 - 02:50 AM

(editing for code clean up, sorry)
After the prior one that I figured out myself last minute it does, however, bring up an entirely different issue.

Here is the code (clipped down) then I will explain more

switch (@$forum)       /*Open of forum switch*/
 {
   case "1":    /*Should be ?forum=general */
     {
        switch (@$view)   /*Open of view switch*/
           {
               case "topics":/*Should be ?forum=1&view=topics*/
                  {
                  echo "viewtopics 1 ";
                  break; /* ends ?= caseblock */
                  }
               case "posts":  /*Should be ?forum=1&view=posts*/
                  {
                  echo "viewposts 1 ";  
                  break; /* ends ?= caseblock */
                  }

                  break; /* ends ?= caseblock */
                  default: echo "1 Default ";
            }/*End of view switch*/
       } /*End of Case 1*/


  case "2": /*Should be ?forum=2 */
      {
          switch (@$view)  /*Open of view switch*/
             {
                case "topics":  /*Should be ?forum=2&view=topics*/
                  {
                   echo "viewtopics 2 ";
                   break; /* ends ?= caseblock */
                   }
                   case "posts":/*Should be ?forum=2&view=posts*/
                   {
                   echo "viewposts 2 ";
                   break; /* ends ?= caseblock */
                   }
                   break; /* ends ?= caseblock */
                   default: echo "2 Default ";
             }         /*End of view switch*/

    }                /*End of Case 2*/



break; /* ends ?= caseblock */
/*By default show the main form page*/
default: include("forumbody.php");



    }
/*End of forum switch*/


What is working
forumstest.php = forumbody.php included, nothing else

Not working
forumstest.php?forum=1 responds with "1 Default 2 Default"
forumstest.php?forum=1&view=topics responds with "viewtopics 1 viewtopics 2"

So initially I thought it was some "case" collision problem. However all
forumstest.php?forum=2 requests do not include the forum=1 information. In other words they are working fine.

So what can I look at/do to prevent the second case from throwing stuff in if the first case is met? Why is the second case even doing anything when case "2": /*Should be ?forum=2 */ is not met?

Adding in a die() statement at the end of the case 1 stuff is not an option as there are things further down this script that I need to execute. I know I could call it with an include and add a die statement, but I would rather see if there is an actual way to properly do this, and figure out why it is even acting this way to begin with.

Any help is greatly appreciated.


I apologize for the oddly spaced code. I tried fixing it with an edit but it seems like the code box options on the message board are throwing in tabs spaces





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users