473,473 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Referencing a File or Folder

I'm trying to point to an include file from php like so:

<?php require('/main/includes/nav_stripe.php');?>

That approach is perfectly fine when trying to point to a folder
INCLUDES inside folder MAIN on the root IN HTML. However, php is
producing errors.

Is there a solid safe way to reference a file/folder regardless of how
many levels up or down it is?

May 8 '06 #1
4 1611
bbs
Do Google search
Check User Contributed Notes in http://tw2.php.net/require

-=-=-=-=-
http://www.livibetter.com

May 8 '06 #2
TristaSD wrote:
I'm trying to point to an include file from php like so:

<?php require('/main/includes/nav_stripe.php');?>

That approach is perfectly fine when trying to point to a folder
INCLUDES inside folder MAIN on the root IN HTML. However, php is
producing errors.

Is there a solid safe way to reference a file/folder regardless of how
many levels up or down it is?


When you use absolute filenames, PHP references it to the OS's file system root,
not the root directory of your website. So unless you have a file on your
computer called

/main/includes/nav_stripe.php

this will fail.

If you want to be relative to your website's root directory, you need to use:

<?php require($_SERVER['DOCUMENT_ROOT'] . '/main/includes/nav_stripe.php'); ?>

or something similar.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 8 '06 #3
TristaSD wrote:
I'm trying to point to an include file from php like so:

<?php require('/main/includes/nav_stripe.php');?>

That approach is perfectly fine when trying to point to a folder
INCLUDES inside folder MAIN on the root IN HTML. However, php is
producing errors.

Is there a solid safe way to reference a file/folder regardless of how
many levels up or down it is?

Set the include_path configuration directive to an absolute path (where
you then keep your include files) and then all you need do is include
the filename (with no path).

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
The world is my country,
Science, my religion.
*****************************
May 8 '06 #4
Chuck Anderson wrote:
TristaSD wrote:
I'm trying to point to an include file from php like so:

<?php require('/main/includes/nav_stripe.php');?>

That approach is perfectly fine when trying to point to a folder
INCLUDES inside folder MAIN on the root IN HTML. However, php is
producing errors.

Is there a solid safe way to reference a file/folder regardless of how
many levels up or down it is?


Set the include_path configuration directive to an absolute path (where
you then keep your include files) and then all you need do is include
the filename (with no path).


That's great if you have access to the configuration. Most shared hosts don't
allow it. And doing it in .htaccess is less efficient.

This works with any Apache host and doesn't require .htaccess.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Macka | last post by:
A few pieces of information first: * I have a class called Folder which represents a row of data in a database table. The data access side of things is not an issue. * The table has a parent...
2
by: Chang | last post by:
Actually I am not sure how to word this question, I will try my best. Remove all the HTML code from a give *.html file and show it as text file. I am using WebBrowser to open (local) html...
3
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a...
5
by: David C | last post by:
I am not fully understanding how to refer to another file in the aspx page. There is one style sheet which I need to refer to and it is in the root directory <LINK href="styles.css"...
2
by: Chris Ashley | last post by:
I've written a C++ Wrapper DLL which I need to add a reference to in my ASP.Net project. This in turn is dependent on the DLL it wraps which is in turn dependent on some other DLLs. When I...
4
by: steve_barker333 | last post by:
Hi guys! I keep getting the following error reported by VS 2005 in my ASP.NET 2.0 web project: "The type or namespace name 'MainPages_XXX' could not be found (are you missing a using...
1
by: Dave Anson | last post by:
What is the recommended practice for referencing assemblies in a project from other solutions? I am using Visual Studio 2005 Team System. I have several assemblies in another solution which will...
1
by: Henry Stock | last post by:
I am having trouble referencing a theme in my ASP.NET project. I was following a model that allowed for multiple themes. So The theme that I have is stored in named "Base" under the App_Theme...
1
by: Tom | last post by:
My unsigned DLL works in my project that references it as long as I set Copy Local = true. Now I have signed the DLL with the sn.exe generated keys but have not yet moved the DLL into the GAC. ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.