hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : including file for links
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

including file for links

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-15-2002, 02:53 AM
brcolow brcolow is offline
WHT 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"); ?>
Ive tried the following:
../links.html
/links.html but they all fail
is it my php mabye? thanks fior the help,
-Mike

Reply With Quote


Sponsored Links
  #2  
Old 09-15-2002, 02:58 AM
prosayist prosayist is offline
Junior 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

Reply With Quote
  #3  
Old 09-15-2002, 03:24 AM
brcolow brcolow is offline
WHT Addict
 
Join Date: Sep 2002
Location: az
Posts: 168
its not in the same directory.... so which one should i use?

Reply With Quote
Sponsored Links
  #4  
Old 09-15-2002, 03:30 AM
brcolow brcolow is offline
WHT 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

Reply With Quote
  #5  
Old 09-15-2002, 03:49 AM
prosayist prosayist is offline
Junior 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]*/
well what directory is it in? Relative URLs should work as should anything that uses the filesystem structure
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

Reply With Quote
  #6  
Old 09-15-2002, 04:01 AM
brcolow brcolow is offline
WHT 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 anything


Last edited by brcolow; 09-15-2002 at 04:11 AM.
Reply With Quote
  #7  
Old 09-15-2002, 05:39 AM
Myth_Pharoah Myth_Pharoah is offline
Newbie
 
Join Date: Sep 2001
Location: Pune, Maharashtra, India.
Posts: 24
$_SERVER['DOCUMENT_ROOT']

Use that.

Reply With Quote
  #8  
Old 09-15-2002, 01:12 PM
brcolow brcolow is offline
WHT 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?

Reply With Quote
  #9  
Old 09-15-2002, 05:18 PM
brcolow brcolow is offline
WHT Addict
 
Join Date: Sep 2002
Location: az
Posts: 168
bump

Reply With Quote
  #10  
Old 09-15-2002, 05:20 PM
Alturus Alturus is offline
Newbie
 
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 ?

__________________
http://www.alturus.ca
Professional Web-Design/Programming

Your CSS2.0/XHTML table-less guru. Pushing for properly coded webpages.


Last edited by Alturus; 09-15-2002 at 05:28 PM.
Reply With Quote
  #11  
Old 09-15-2002, 07:51 PM
Samuel Samuel is offline
Web Hosting Master
 
Join Date: May 2002
Location: Modesto, CA
Posts: 3,414
<?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]

Reply With Quote
  #12  
Old 09-15-2002, 10:34 PM
brcolow brcolow is offline
WHT 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

Reply With Quote
  #13  
Old 09-16-2002, 09:49 AM
AboveCenter AboveCenter is offline
Junior 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 ...

Reply With Quote
  #14  
Old 09-17-2002, 12:31 AM
prosayist prosayist is offline
Junior 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*/
?>
[EDIT]manual linewrap[/EDIT]

__________________
WYSIWYG


Last edited by prosayist; 09-17-2002 at 12:38 AM.
Reply With Quote
  #15  
Old 09-27-2002, 12:26 AM
brcolow brcolow is offline
WHT Addict
 
Join Date: Sep 2002
Location: az
Posts: 168
makes me laugh, i go it to works the f**ing slahses were backwards LOLOL

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
File Sync Software Provider ownCloud Secures $2.5M Funding Round to Grow Partner Channel Web Hosting News 2012-11-26 14:20:54
Google+ Business Pages – Implications for Search Marketing Blog 2012-01-25 09:58:46
SingleOS Launches Fuscan Linux Cloud 2.0 Web Hosting News 2011-08-12 19:09:05
Security Firm Trustwave Launches Cloud-Based File Integrity Monitor Web Hosting News 2011-06-21 18:47:57
Web Host WebHostingBuzz Partners with Cloud Platform SMEStorage Web Hosting News 2011-06-01 18:10:25


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?