Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Including local php file?
Old 04-20-2008, 05:24 PM Including local php file?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
I have my main navigational php files in the root directory which I'm including in other pages that are buried deep within other directories. I thought adding a slash to the file name like "/nav.php" meant to look for the file in the root directory, but this isn't working. Any ideas why?


Thanks,

Nathand

Last edited by Nathand; 04-20-2008 at 05:25 PM.. Reason: typo
Nathand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-20-2008, 05:46 PM Re: Including local php file?
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
/ means root, literally the root of the filesystem. It does not mean root of your public_html, or root of your user directory. You might be confused because some hosting providers have the FTP server emulate "/" to mean the root of your home directory.

You need to find the real path to your files. For example, it might be /home/nathand/public_html/nav.php.

If you are unsure, simplest way is probably to just create a sample PHP file with:
PHP Code:
echo __FILE__
That'll give you the full system path to that file.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 04-20-2008, 06:00 PM Re: Including local php file?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Ok my previous server probably did emulate the "/" as the root directory like you said. I think I'm just going to add a variable called "$basedir" to the top of each php file and echo that out before each link.


Thanks for your reply,

Nathand
Nathand is offline
Reply With Quote
View Public Profile
 
Old 04-20-2008, 06:04 PM Re: Including local php file?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
$_SERVER['DOCUMENT_ROOT'] is what you are looking for:
http://www.php.net/manual/en/reserve...les.server.php
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-20-2008, 07:19 PM Re: Including local php file?
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
You could always find the actual directory path of the file by making it give you an error. haha.

PHP Code:
echo $example
echo $example2 
missing the ';'
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Including local php file?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65358 seconds with 12 queries