Jump to content

Switch Pulling Wrong Page


Q695

Recommended Posts

Why are the words causing the switch to die

switch ($page) {
case "1":
include 'explore.php';
break;
case "see":
include 'see.php';
break;
case "kill":
include 'kill.php';
break;
case "2":
include 'inventory.php';
break;
case "3":
include 'guilds.php';
break;
default:
echo "entry";
}

Link to comment
https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/
Share on other sites

<?php
/* this defaulting to see.php
*/
if (isset($_GET["action"])){
$action = $_GET["action"];
echo "act" . $action;
} else {
$action=0;
}
switch ($action) {
case "see":
include 'see.php';
break;
case "kill":
include 'kill.php';
break;
default:
include 'explore_main.php';
}
?>

Took a while but solved it somehow by setting a negative case value outside of the data bounds:

<?php
if (isset($_GET["action"])){
$action = $_GET["action"];
echo "act" . $action;
} else {
$action=-10;
}
switch ($action) {
case "see":
include 'see.php';
break;
case "kill":
include 'kill.php';
break;
default:
include 'explore_main.php';
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.