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"; } Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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: Quote Link to comment 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 Quote Link to comment 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'; } ?> Quote Link to comment 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 Quote Link to comment 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; } ?> Quote Link to comment Share on other sites More sharing options...
Christian F. Posted September 27, 2012 Share Posted September 27, 2012 (edited) 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. Edited September 27, 2012 by Christian F. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.