Jump to content

GET variables not working when I include the file.


JJBlaha

Recommended Posts

The problem is this.

 

index.php is this

 

<? include('main/index.php'); ?>

 

main/index.php is this

 

$content = $_GET['content'];
echo "con is $content";

 

when i put in index.php?content=blahblah

 

It echos 'con is', but if i change index.php to what main/index.php is, it con is blahblah.  Anyone know why?

have you tried outputting the variable straight from the URL. Is it actually posting? Just examine it i'm sure it'll be something simple. If you see some contents of the included file then it doesn't matter about being on a subdomain etc. Just look at the get method and make sure it's back to itself.

 

<?php ECHO "$_GET['content']"; ?>

 

Snooble

The get variables are undefined if they are in the included file on the main site (www.domain.com/main/index.php) but they work perfectly on the regular subdomain file (sub.domain.com/index.php).  The code used in every case was the exact same, the only difference is that it is either included or is not.

so you're saying the included file doesn't get the $_GET variables? something like this?...

 

page1.php

<?php
include('page2.php');
?>

 

page2.php

<?php
echo $_GET['test'];
?>

 

a call to page1.php?test=test doesn't do anything?

 

sounds like a server problem....

Sorry, I made a mistake in what I was saying earlier, the correct representation of my problem is as follows.

 

sub.domain.com/page1.php

<?php

include('http://www.domain.com/main/page2.php');

?>

 

www.domain.com/main/page2.php

<?php

echo "Test is ";

echo $_GET['test'];

?>

 

http://sub.domain.com/page1.php?test=test returns

Test is

Archived

This topic is now archived and is closed to further replies.

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