Jump to content

[SOLVED] Include Problems


killfall

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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]) ;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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