sean14592 Posted December 8, 2008 Share Posted December 8, 2008 Ok, well my problem is that I have a link which goes to for example http://mysite.com/index.php?page=listing&id=1 Now, The PAGE variable sets what the page is, simple. Then the ID variable tells the included PAGE what content to include corrisponding to the ID. I have a problem with the second part, the PAGE is included, but then the included page does not see the ID variable. Heres some of my code: Bit that includes the page <?php //display main content $pagesavail = array ('home','moto','freetemp','freetempshow'); $var1 = sanitize($_GET['oc']); if (in_array($var1, $pagesavail)) { include("http://mysite.com/include/".$var1.".php"); } else { include("http://mysite.com/include/home.php"); } ?> Bit that includes the content based on ID <?php echo ("-".$_GET['id']."-<br>"); //Just to test ?> As you can see from the code above the included page should display -1- (if the ID variable was set to 1), Though im seeing -- Cheers Sean Quote Link to comment https://forums.phpfreaks.com/topic/136073-_get-variables-not-working-in-an-included-php-file/ Share on other sites More sharing options...
rhodesa Posted December 8, 2008 Share Posted December 8, 2008 by including the files with the FULL url, you are including the 'generated' version of the page. So it's just as if you put http://mysite.com/include/listing.php into your browser, did a view source, and included that. what you want, is to include the PHP source. to do this, provide the FILESYSTEM path to the file. something like: include("include/".$var1.".php"); Quote Link to comment https://forums.phpfreaks.com/topic/136073-_get-variables-not-working-in-an-included-php-file/#findComment-709581 Share on other sites More sharing options...
sean14592 Posted December 8, 2008 Author Share Posted December 8, 2008 Thats awesome. you guys are amazing! Thanks all, have a good XMAS! Cheers Sean Quote Link to comment https://forums.phpfreaks.com/topic/136073-_get-variables-not-working-in-an-included-php-file/#findComment-709607 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.