Jump to content

Get Case selection problem


thefollower

Recommended Posts

I'm not sure if i got my case correct but I got a Get link which runs through a case but one link does one thing the other does something else even though they should be both doing the same action this is what i have firstly:

 

<div id="bv_" style="position:absolute;left:686px;top:686px;width:50px;height:48px;z-index:40" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><br>
<a href="reportletters.php?report=2">Report</a></font></div>
<div id="bv_" style="position:absolute;left:686px;top:836px;width:50px;height:48px;z-index:30" align="left">
<font style="font-size:13px" color="#FFFFFF" face="Arial"><br>
<a href="reportletters.php?report=3">Report</a></font></div>

 

This is the Get Links.

 

Then i have:

 

if(isset($_GET['report'])){
    switch($_GET['report']){
        case '1':

$MessageID = $rowone['MessageID'];
$Update = "UPDATE messages SET Status = '3' WHERE MessageID='$MessageID'";
$result = mysql_query($Update) or die(mysql_error());
        break;
         case '2':

$MessageID = $rowtwo['MessageID'];
$Update = "UPDATE messages SET Status = '3' WHERE MessageID='$MessageID'";
$result = mysql_query($Update) or die(mysql_error());
        break;
        case '3':

$MessageID = $rowthree['MessageID'];
$Update = "UPDATE messages SET Status = '3' WHERE MessageID='$MessageID'";
$result = mysql_query($Update) or die(mysql_error());
	default:
            die ("invalid message selected");
        break;
  
   }
}

 

Now what happens is if i do report=2 on the GET then nothing happens (Which is correct as there is no message 2 in this situation)

But if i do report=3 it gives me the "Invalid message selected" even though there is no message 3 either.. so what it should be doing is basically nothing rather than producing error...

 

What i dont get is why 2 doesn't yet 3 does... is it because the default is below 3? Or something?

Link to comment
https://forums.phpfreaks.com/topic/75555-get-case-selection-problem/
Share on other sites

you forgot the break

 

 

case '3':

$MessageID = $rowthree['MessageID'];
$Update = "UPDATE messages SET Status = '3' WHERE MessageID='$MessageID'";
$result = mysql_query($Update) or die(mysql_error());
break;
	default:
            die ("invalid message selected");
        break;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.