Results 1 to 15 of 15
Thread: including file for links
-
09-15-2002, 02:53 AM #1WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
including file for links
Hey, im trying to do something where i include an html file with php using this line
PHP Code:<? include ("/www/www.flashstand.com/links.html"); ?>
../links.html
/links.html but they all fail
is it my php mabye? thanks fior the help,
-Mike
-
09-15-2002, 02:58 AM #2Junior Guru Wannabe
- Join Date
- Dec 2001
- Location
- New Hampshire
- Posts
- 93
where're you tryinna include this from?
evidently, this is your document root;
if that's the case, you can use
PHP Code:<?include("$DOCUMENT_ROOT/links.html");?>
/*if the calling document is in the CWD, you can just do */
<?include("./links.html");?>WYSIWYG
-
09-15-2002, 03:24 AM #3WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
its not in the same directory.... so which one should i use?
-
09-15-2002, 03:30 AM #4WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
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
-
09-15-2002, 03:49 AM #5Junior Guru Wannabe
- Join Date
- Dec 2001
- Location
- New Hampshire
- Posts
- 93
oh yeah, before you can use $document_root you must
PHP Code:global $HTTP_SERVER_VARS;
/*then document_root will be defined*/
<?include("$DOCUMENT_ROOT/links.html");?>
/*[EDIT='this line was way too long']
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[/EDIT]*/
e.g.:
PHP Code:<? 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"); ?>WYSIWYG
-
09-15-2002, 04:01 AM #6WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
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 anythingLast edited by brcolow; 09-15-2002 at 04:11 AM.
-
09-15-2002, 05:39 AM #7Newbie
- Join Date
- Sep 2001
- Location
- Pune, Maharashtra, India.
- Posts
- 24
$_SERVER['DOCUMENT_ROOT']
Use that.
-
09-15-2002, 01:12 PM #8WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
i did this....
PHP Code:<?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?
-
09-15-2002, 05:18 PM #9WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
bump
-
09-15-2002, 05:20 PM #10Newbie
- Join Date
- Aug 2002
- Location
- Canada
- Posts
- 22
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 ?Last edited by Alturus; 09-15-2002 at 05:28 PM.
http://www.alturus.ca
Professional Web-Design/Programming
Your CSS2.0/XHTML table-less guru. Pushing for properly coded webpages.
-
09-15-2002, 07:51 PM #11Web Hosting Master
- Join Date
- May 2002
- Posts
- 3,416
<?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.dotGig
<:<: [Fruit eating linux administrator]
-
09-15-2002, 10:34 PM #12WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
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
-
09-16-2002, 09:49 AM #13Junior Guru Wannabe
- Join Date
- Sep 2002
- Location
- Minnesota
- Posts
- 65
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 ...
-
09-17-2002, 12:31 AM #14Junior Guru Wannabe
- Join Date
- Dec 2001
- Location
- New Hampshire
- Posts
- 93
PHP Code:<?
/* 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*/
?>Last edited by prosayist; 09-17-2002 at 12:38 AM.
WYSIWYG
-
09-27-2002, 12:26 AM #15WHT Addict
- Join Date
- Sep 2002
- Location
- az
- Posts
- 168
makes me laugh, i go it to works the f**ing slahses were backwards LOLOL