Q695 Posted September 26, 2012 Share Posted September 26, 2012 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 More sharing options...
Jessica Posted September 26, 2012 Share Posted September 26, 2012 Your question makes no sense. The only advice I can offer is make sure error reporting is on and try using require_once instead. Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381133 Share on other sites More sharing options...
Christian F. Posted September 26, 2012 Share Posted September 26, 2012 I recommend that you read this article. Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381144 Share on other sites More sharing options...
Q695 Posted September 26, 2012 Author Share Posted September 26, 2012 I tried setting it at the beginning of the applet, and it didn't work. Here is the error statement Notice: Undefined index: variable Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381145 Share on other sites More sharing options...
Jessica Posted September 26, 2012 Share Posted September 26, 2012 That error has nothing to do with the code posted. Post the entire error including line number, and the code that is around that line number. Applet? Really? :eyeroll: Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381148 Share on other sites More sharing options...
Q695 Posted September 26, 2012 Author Share Posted September 26, 2012 I tried removing the 2 text cases it worked fine, but when I rewrite them I get the error in the switch statement Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381150 Share on other sites More sharing options...
Q695 Posted September 27, 2012 Author Share Posted September 27, 2012 <?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'; } ?> Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381238 Share on other sites More sharing options...
Q695 Posted September 27, 2012 Author Share Posted September 27, 2012 the var string is "?page=1", and it goes to see.php Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381241 Share on other sites More sharing options...
Q695 Posted September 27, 2012 Author Share Posted September 27, 2012 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; } ?> Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381254 Share on other sites More sharing options...
Christian F. Posted September 27, 2012 Share Posted September 27, 2012 You're using "page" in the URL, but you're asking for $_GET['action']. That's your real problem. The fact that it defaulted to "see.php" is because 0 == 'see', due to the way type auto casting works. Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381287 Share on other sites More sharing options...
ManiacDan Posted September 27, 2012 Share Posted September 27, 2012 Christian is right. You're also using a lot of buzzwords that make no sense. PHP scripts are not applets. There's no such thing as a "data bounds." And you need to read up on how PHP handles comparisons between data types Link to comment https://forums.phpfreaks.com/topic/268829-switch-pulling-wrong-page/#findComment-1381288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.