PFMaBiSmAd Posted July 29, 2008 Share Posted July 29, 2008 When you include a page using a URL, php makes a http request to fetch that page (even if the page is on your web server.) This invokes a separate instance/child-process of the web server to parse your page, the same as if you browsed to it. In this case, variables in the main code are NOT available to the included code. For the example you just posted, you WOULD need to put a GET parameter on the end of the URL. Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-602831 Share on other sites More sharing options...
killfall Posted July 29, 2008 Author Share Posted July 29, 2008 When you say put a GET parameter on the end of the URL What do you mean by that. Im sorry I'm not too good with PHP yet. Could you please post an example? Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-602905 Share on other sites More sharing options...
PFMaBiSmAd Posted July 29, 2008 Share Posted July 29, 2008 You are including files from your own site using a URL. Why? When you do this, you only get any content that is output by that file. Main program variables are not directly available in the included code and any thing the included code changes is not available in the main program. Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-602906 Share on other sites More sharing options...
killfall Posted July 29, 2008 Author Share Posted July 29, 2008 So what other ways are there that I can include code? because I want one page then have all the info on that page as variables so if i change anything I only have to change 1 page. Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603118 Share on other sites More sharing options...
MasterACE14 Posted July 29, 2008 Share Posted July 29, 2008 try include_once(); rather then include(); Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603121 Share on other sites More sharing options...
killfall Posted July 29, 2008 Author Share Posted July 29, 2008 Nah that didn't work but I have found that if I name the page to be included r2d2.txt instead of r2d2.php then it works fine. There is probably a better way to do it than that so I'll keep watchin this thread if anyone comes up with it. But I'll just use .txt files for now. Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603129 Share on other sites More sharing options...
chacha102 Posted July 29, 2008 Share Posted July 29, 2008 A practice I like to use for all of my include files is to name them '.inc' ( for 'include' ). Its treated as a text file I believe, as other extensions that aren't recognized. It gets processed as a part of the script, instead of .php which gets processed as its own file. (It would also be a good idea to name it .inc, or another non-used extension, so if you'd like to limit the extensions the server allows the users to view, its much easier. I know a programmer that has most of his servers limit the extensions users can view to .php, .html, etc.) Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603147 Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2008 Share Posted July 30, 2008 By naming your files anything other than .php ANYONE that finds or guesses the file name can browse to those files and see the php code in them. If you do this, DON'T put anything in them like database usernames or passwords. By including a file using a URL, you are doubling the time it takes that page to load, because the http request for the include file takes the same amount of time as browsing to that file. If you include the file through the file system, the way it is intended and normally done, it will only take something in the range of a few 100 micro seconds to open and read the file. killfall, as to your question about any other way to include code, I refer you to the php manual page for the include() function - http://www.php.net/include/ Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603203 Share on other sites More sharing options...
samshel Posted July 30, 2008 Share Posted July 30, 2008 if you want to use the HTML of the URL included and pass guid there try this. $guid = ($_GET[guid]) ; //Header Content if($header_include == 'y') { $header_content = 'http://web.kaedo-online.net/pages/'.$content_id.'_header.php?guid='.$guid; } else { did you try this ?? also you will have to add this line in the _header file at the top $guid = ($_GET[guid]) ; Quote Link to comment https://forums.phpfreaks.com/topic/116988-solved-include-problems/page/2/#findComment-603457 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.