Question: I have the follwing code:

```
switch ((int)$_GET["loanprovider"]) {
    case ((int)$_GET["loanprovider"] > 1):
        $sql_loanprovider1a = " l.id in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        $sql_loanprovider1b = " l.loanid in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        break;
    default:
        break;
}

```

If i run the page without setting LOANPROVIDER in the URL, the SWITCH still enters the first case and not the DEFAULT. How come??

/Bob

Answer: 
I would first check if $\_GET["loanprovider"] is set because if you don't set loanprovider in the url it will be undefined and undefined does not have to be "0" it can be something else. In this case it would be probably some value that makes your statement ((int)$\_GET["loanprovider"] > 1): true.

The correct code would be:

```
if (isset((int)$_GET["loanprovider"]))
{
  switch ((int)$_GET["loanprovider"]) {
    case ((int)$_GET["loanprovider"] > 1):
        $sql_loanprovider1a = " l.id in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        $sql_loanprovider1b = " l.loanid in (select la.loanid from loan_approvals la where la.bankid = ".$_GET["loanprovider"].") and";
        break;
    default:
        break;
  }
}  

```
I'm no PHP expert, but I think your redundant use of loanprovider in the switch statement is a clue. I think if you don't set loanprovider you will have an empty value of some sort, which goes in the parameter to switch, and then you use a similar value in the case. assume `(int)$_GET["loanprovider"]` is 0. Then the expression `(int)$_GET["loanprovider"] > 1` will also return 0 because 0 is not greater than 1. What you end up with is essentially:

```
switch (0) {
case 0:
  // your code
  break;
default:
  break;
}

```

Because 0 == 0, you end up in the first case.