PHP variable not available after switch-ThrowExceptions

Exception or error:

I’m trying to set a result from a set of code into a variable, let’s call it $Msg, however after the switch the variable doesn’t seem to be set anymore. Sample code below:

if(isset($_POST)) {
    switch($_POST['formid']) {
        case "AOTEMP":
            //Other working code here removed
            $Msg = 'Succeeded';
    if(!isset($Msg)) { $Msg = "Failed"; }
        echo "<script>parent.self.location='http://SERVER/FILE.php?result=Success&Msg=".$Msg."';</script>";
        //process errors here...

Every time this returns Failed as the value of $Msg indicating that the previously set $Msg was no longer set when it reached the end of the switch.

I’m not sure what I’m missing but this seems like it should work. Any help would be appreciated.

Just to clarify I know the switch is working because there is other code inside the case that gets executed successfully.

How to solve:

Reset IIS on one server and it began working on 1 of 32 servers in the load balanced pool, after an IIS reset on the others it’s started working there too. Case opened with Microsoft, their devops team is looking into it, left 2 servers broken for them to test, only time will tell.

Leave a Reply

Your email address will not be published. Required fields are marked *