adamriley Posted May 9, 2010 Share Posted May 9, 2010 Red.php <?php require($_SERVER["DOCUMENT_ROOT"]."/Game/Main_one.php"); $spot = $_GET['Spot']; if ($spot = "Lee") { $SESSION['dir'] = '3'; } elseif ($spot = "Adam") { $SESSION['dir'] = '2'; } else { $SESSION['dir'] = '1'; } echo $SESSION['dir']; $ss = $_SESSION['dir']; require($_SERVER["DOCUMENT_ROOT"]."/Game/$ss/adam.php"); session_destroy(); ?> Main_one.php <?php session_start(); // start the session ?> When the url is "http://localhost/Game/red.php?Spot=Adam" I hope that the $SESSION['dir'] = 2 But from echoing it is 3 This is the page i get 3 Warning: require(C:/xampp/htdocs/Game//adam.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\Game\Red.php on line 13 Fatal error: require() [function.require]: Failed opening required 'C:/xampp/htdocs/Game//adam.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Game\Red.php on line 13 Any one tell me why Quote Link to comment Share on other sites More sharing options...
niranjan81 Posted May 9, 2010 Share Posted May 9, 2010 Correct Way: <?php require($_SERVER["DOCUMENT_ROOT"]."/Game/Main_one.php"); $spot = $_GET['Spot']; if ($spot == "Lee") { $SESSION['dir'] = '3'; } elseif ($spot == "Adam") { $SESSION['dir'] = '2'; } else { $SESSION['dir'] = '1'; } echo $SESSION['dir']; $ss = $_SESSION['dir']; require($_SERVER["DOCUMENT_ROOT"]."/Game/$ss/adam.php"); session_destroy(); ?> nevermind we all have done these things Quote Link to comment Share on other sites More sharing options...
ignace Posted May 9, 2010 Share Posted May 9, 2010 if ($spot == "Lee") { $SESSION['dir'] = '3'; } elseif ($spot == "Adam") { $SESSION['dir'] = '2'; } Note == Quote Link to comment Share on other sites More sharing options...
adamriley Posted May 9, 2010 Author Share Posted May 9, 2010 Thanks both of you for your quick reply and the if statement does work now but it does not require the file look for the gap 2 Warning: require(C:/xampp/htdocs/Game/ /adam.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\Game\Red.php on line 14 Fatal error: require() [function.require]: Failed opening required 'C:/xampp/htdocs/Game/ /adam.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Game\Red.php on line 14 Quote Link to comment Share on other sites More sharing options...
adamriley Posted May 9, 2010 Author Share Posted May 9, 2010 Thanks found the bug there is no "_" in the session e.g $SESSION and not $_SESSION 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.