
|
View Full Version : including file for links
brcolow 09-15-2002, 02:53 AM Hey, im trying to do something where i include an html file with php using this line
<? include ("/www/www.flashstand.com/links.html"); ?>
Ive tried the following:
../links.html
/links.html but they all fail :(
is it my php mabye? thanks fior the help,
-Mike
prosayist 09-15-2002, 02:58 AM where're you tryinna include this from?
evidently, this is your document root;
if that's the case, you can use
<?include("$DOCUMENT_ROOT/links.html");?>
/*if the calling document is in the CWD, you can just do */
<?include("./links.html");?>
brcolow 09-15-2002, 03:24 AM its not in the same directory.... so which one should i use?
brcolow 09-15-2002, 03:30 AM errrr it said..
Notice: Undefined variable: DOCUMENT_ROOT in D:\www\www.flashstand.com\dl\index.php on line 48
Warning: Failed opening '/links.html' for inclusion (include_path='.;c:\php4\pear') in D:\www\www.flashstand.com\dl\index.php on line 48
prosayist 09-15-2002, 03:49 AM oh yeah, before you can use $document_root you mustglobal $HTTP_SERVER_VARS;
/*then document_root will be defined*/
<?include("$DOCUMENT_ROOT/links.html");?>
/*
I have global $HTTP_SERVER_VARS;
included before anything else
so I can do things like that anywhere
without needing to think about it
which is why I didn't think to include it before..
please excuse me for my apparent ignorance*/
well what directory is it in? Relative URLs should work as should anything that uses the filesystem structure
e.g.:
<? include ("/www/www.flashstand.com/links.html"); ?>
/* or */
<?global $HTTP_SERVER_VARS;
include("$DOCUMENT_ROOT/links.html");?>
/* or */
<?include("../../links.html");?>
/* (but only if the calling page is two directories below the 'links.html' file) */
/* BUT NOT */
<?include("http://www.flashstand.com/links.html"); ?>
brcolow 09-15-2002, 04:01 AM I think on the server, Global Variables are turned off. Do I need direct access to the server to turn them on?! Also, I tried the first method, it didn't work. And the 2nd one I think i need Global Variables to be turned on. And links.html is in the base directory. Thanks.
Mike
Edit: The server is windows if this means anything
Myth_Pharoah 09-15-2002, 05:39 AM $_SERVER['DOCUMENT_ROOT']
Use that.
brcolow 09-15-2002, 01:12 PM i did this....
<?include("$_SERVER['DOCUMENT_ROOT']/links.html");?>
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\www\www.flashstand.com\dl\index.php on line 48
did i type that wrong?
brcolow 09-15-2002, 05:18 PM bump :(
Alturus 09-15-2002, 05:20 PM Anytime you use '/something' whether it's a link, image, or whatever, '/' refers to the root dir of the site.
But obviously that doesn't work... so I don't know...
Is the file you want to inclue above or below the index.php ?
Samuel 09-15-2002, 07:51 PM <?include("$_SERVER['DOCUMENT_ROOT']/links.html");?>
<?php include ("/home/devimgc/incs/global/globalheader.php"); ?>
First you're missing spaces, and not telling the server to parse it.
brcolow 09-15-2002, 10:34 PM ok... well i have alot of index.php's but the main one (thre homepage) i think is the one ur talking about, and links.html is in the SAME directory, but the pages i want to use it on are ALL below the directory....thanks
-Mike
AboveCenter 09-16-2002, 09:49 AM If the file you are loading (index.php) and the file you are trying to include (links.html), I don't think you need to note anything with your root folder. Just use relative paths: <?*include*("/links.html");*?>. This will load links.html from the home directory (the base web folder). I may be misunderstanding the problem, or maybe it's different on a Windows machine ...
prosayist 09-17-2002, 12:31 AM <?
/* like you said before, */
include("$_SERVER['DOCUMENT_ROOT']/links.html");
/* only you should define first, else,
like Samuel said "not telling the server to parse it."
the server doesn't know that what $_SERVER['DOCUMENT_ROOT'] is until it's too late.
THEN, you can use it like: */
$docroot = $_SERVER['DOCUMENT_ROOT'];
include $docroot."/links.html";
/* or simply, like AboveCenter said, */
include "/links.html";
/*but, like you said "is it my php mabye?",
I just upgraded to 4.2.2 from 4.1.3 and I think including
something that starts with "/" doesn't seem to work correctly in
an older version (but now I don't remember already) so maybe
you should define it, as in '$docroot' before or one of the methods below.
if you happen to be including something from the same directory
as the document you're including at some point, do it like this */
include "./included_document_filename.ext";
/* or, if you're including at a predetermined relative distance above in the directory structure, (i.e. 2 folders above) */
include "../../included_document_filename.ext";
/* and if you want to include something from a directory below, */
include "foldername/path/to/included_document_filename.ext";
/*
and you said "Global Variables are turned off. Do I need direct
access to the server ", and I say */
$url="http://www.php.net/manual/en/function.ini-set.php";
/* or, add to .htaccess (or maybe.. windows... :rolleyes: )
php_value register_globals 1*/
?>
manual linewrap
brcolow 09-27-2002, 12:26 AM makes me laugh, i go it to works the f**ing slahses were backwards LOLOL:D :D :D :D
|