Jump to content

need newbie help !!


adamriley

Recommended Posts

 

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
Share on other sites

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  :P

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.