Jump to content

[SOLVED] The switch statement


Pandolfo

Recommended Posts

Hey everyone,

 

 

I have a bit of code i'm working on which, despite trying everything which normally works, doesn't behave the way its written to. The whole thing works fine in my local environment, but when i upload it to the server it dies.I'm concatenating three variables, each one digit in length, to create a three digit result code. I know the code is created correctly, resulting in just three digits. This code is fed to the switch statement which then displays a block of html specific to the code. Simple right? The problem is that the switch statement doesn't seem to like the concatenated variable. Instead of processing the argument and displaying the code, it heads straight for the default statement. If i hard-code the variable to any of the possible codes in the switch statement it works just fine. Is it a problem with the switch statement or the concatenation? Any ideas would be a great help. Thanks!

 

$decadecode=$fired.$divorced.$decadenumber;
switch ($decadecode):
case 001:
case 002:
case 003:
echo $marriedemployed;
break;
case 004:
echo $marriedemployedfinal;
break;
case 101:
case 102:
case 103:
echo $firedmarried;
break;
case 104:
echo $firedmarriedfinal;
break;
case 011:
case 012:
case 013:
echo $divorcedemployed;
break;
case 014:
echo $divorcedemployedfinal;
break;
case 111:
case 112:
case 113:
echo $fireddivorced;
break;
case 114:
echo $fireddivorcedfinal;
break;
default :
echo "Your account has been locked as a safety measure. Please contact the site administrator as soon as possible. System code: $decadecode";
endswitch;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.