Jump to content


Photo

(update - no reply needed) default executing even when switch case value is met


  • Please log in to reply
No replies to this topic

#1 Malkavbug

Malkavbug
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 22 March 2006 - 01:52 AM

You know I am probably taking the wrong approach to this to begin with but here we go

You can see what I am trying to do in the code (stripped down with comments)
  switch (@$forum)
    /*Open of forum switch*/
    {
      case "general": /*Should be ?forum=general */
                       switch (@$view)
                              /*Open of view switch*/
                              {
                                case "topics":
                                /*Should be ?forum=general&view=topics*/
                                    {
                                       echo "viewtopics General wheeee ";
                                     /*Temp to see if it is working*/
                                     break;  /* ends ?= caseblock */
                                    }
                                case "posts":
                                /*Should be ?forum=general&view=posts*/
                                    {
                                       echo "viewposts General wheeee yippie!! ";
                                     /*Temp to see if it is working*/
                                     break; /* ends ?= caseblock */
                                    }
                              }
                              /*End of view switch*/
                       default: echo "Gen Default ";
                       break; /* ends ?= caseblock */
   }

The problem is.....

Actually, now that I look at it the problem is that I am an idiot.

Default is executing because I never broke the switch prior to it hitting that line
default: echo "Gen Default ";
break; /* ends ?= caseblock */
changed to
break; /* ends ?= caseblock */
default: echo "Gen Default ";

Works just fine.

So I will just post this for other newbies like myself to reference and learn from my initial mistake.

Love you guys here :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users