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 Link to comment https://forums.phpfreaks.com/topic/201160-need-newbie-help/ 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 Link to comment https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055387 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 == Link to comment https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055388 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 Link to comment https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055394 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 Link to comment https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.