BillyBoB Posted December 8, 2008 Share Posted December 8, 2008 I have a site I have been working on for a while now... I recently switched servers for this site only and the includes that have the extra arguments, ex: www.site.com/index.php?arg=anwser, are failing. Warning: include_once(./includes/Navigation.php?curpg=Home) [function.include-once]: failed to open stream: No such file or directory in /home/game/public_html/Home on line 58 Anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/ Share on other sites More sharing options...
trq Posted December 8, 2008 Share Posted December 8, 2008 Of course it fails, you can't pass arguments to an include unless you are calling them via a url. And then they don't execute within the same process. Can we see how you make this call to include_once? Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710040 Share on other sites More sharing options...
BillyBoB Posted December 8, 2008 Author Share Posted December 8, 2008 I don't see how it wouldn't work because it was working fine on my other server. <?php if($logged==true) { include_once("./includes/Navigation.php?curpg=Home&lgdusr=true"); }else{ include_once("./includes/Navigation.php?curpg=Home"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710054 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 <?php $_GET['curpg'] = "Home"; if($logged==true) { $_GET['lgdusr'] = true; } include_once("./includes/Navigation.php"); ?> Will work. If it worked on your other server, they must of allowed it or had a function to parse out the get variables. I have never seen that work for server-side files in my time. Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710057 Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 no arguemtn can be passed through include without the full url include_once("./includes/Navigation.php?arug=foo"); Is your server looking for a file called Navigation.php?arug=foo not a file called Navigation.php and passing the arguments Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710060 Share on other sites More sharing options...
BillyBoB Posted December 8, 2008 Author Share Posted December 8, 2008 @premiso: That will not work because I am sending the argument to the Navigation page. That way it will highlight the correct tab. It is for dynamic navigation. Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710061 Share on other sites More sharing options...
premiso Posted December 8, 2008 Share Posted December 8, 2008 @premiso: That will not work because I am sending the argument to the Navigation page. That way it will highlight the correct tab. It is for dynamic navigation. That is doing the exact thing you were trying to do, it is sending GET variables, using the ? & etc sends the get variables in a regular url. So if that does not work, maybe your new server as register_globals off and you were accessing the variables not using $_GET? That is the only explanation I can give. The above works fine with this script: index.php <?php include('page.php?id=3&user=jack'); ?> page.php <?php echo $_GET['id'] . ' is ' . $_GET['user'] . '\'s user id!'; ?> Should print out 4 is jack's user id! when index.php is called. Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710066 Share on other sites More sharing options...
BillyBoB Posted December 9, 2008 Author Share Posted December 9, 2008 @gevans: http://us2.php.net/include/ Example #3. premiso your first suggestion worked just took a second to test. Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710070 Share on other sites More sharing options...
gevans Posted December 9, 2008 Share Posted December 9, 2008 @BillyBoB maybe you should read the example before you quote it // Won't work; file.txt wasn't handled by www.example.com as PHP include 'http://www.example.com/file.txt?foo=1&bar=2'; // Won't work; looks for a file named 'file.php?foo=1&bar=2' on the // local filesystem. include 'file.php?foo=1&bar=2'; // Works. include 'http://www.example.com/file.php?foo=1&bar=2'; It says that it won't work! Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710074 Share on other sites More sharing options...
DarkWater Posted December 9, 2008 Share Posted December 9, 2008 Moral of the story: You CANNOT send true GET variables to a locally included file because you aren't actually using an HTTP GET request for it, therefore Apache won't parse a request and send any variables to PHP. Just set the variables before you include the file. Quote Link to comment https://forums.phpfreaks.com/topic/136141-solved-get-arguments-in-include-function/#findComment-710075 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.