Jump to content

?arg=value


roundcorners
 Share

Recommended Posts

Hi, thanks in advance for being patient. I'm very new to php.I am using an if/else statement to load various different includes into one page, so...if (arg=true){ include('path/file.php');} elseif (arg=true) { include('path/file.php');} etc...I am passing the variable at the end of the url so... <a href="url?arg=true#header">click here</a>Now this all works fine on a windows server, but it's not working on a linux machine.Please, please help me, I've looked through the manual, found nothing useful...I'm slowing going mad.thank you

Link to comment
Share on other sites

Are you using that actual code?? You need to look at the $_GET superglobal and the syntax of the equality operator. Were you using ASP on IIS?

if ($_GET['arg'] == "true") {	include('path/file.php');} elseif ($_GET['arg'] == "true") {	include('path/file.php');}

Link to comment
Share on other sites

No I am using php on apache and the following is an examplethe following;if (arg=true){include('path/file.php');} elseif (arg=true) {include('path/file.php');} etc...I am passing the variable at the end of the url so... <a href="url?arg=true#header">click here</a>is actually:if ($tim=true){include('path/file.php');} elseif ($ted=true) {include('path/file.php');} etc...I am passing the variable at the end of the url so... <a href="url?tim=true#header">click here</a>

Link to comment
Share on other sites

thanks, I think I love you, using the $_GET superglobal and the equality operator worked like a charm, thank you, you have solved one ohell of a headache.Just out of interest, why would this have only been a problem on a linux server and not windows?I used the code in my initial query on windows and it did what I expexted.

Link to comment
Share on other sites

That code will behave the same way, no matter whether PHP is running under IIS, Apache, or as a CGI module. Are you sure it was the same file?Edit: I've just realised, on the Windows server, register_globals may have been set, so $_GET['arg'] would have been automatically converted to $arg. However, the first conditional ($tim = true) would have always returned true.

Edited by Synook
Link to comment
Share on other sites

certain it was the same file.Thank you again.Deploying to a Linux server after testing on windows created some very unexpected results for me, but this was the real killer. I suppose in retrospect this example is not a surprise. Without explicitly telling the script to check the GET array, how should the code know where to look?!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...