473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Referring to Parent Folders

I don't know if this is a PHP config problem, or an Apache 1.3/PHP 4
problem, or what. When I include a script, say 2 folders up in the
structure, I'm having to move up to it instead of skipping to root and
moving down to it. Allow me to clarify, let's say my tree structure looks
like so [brackets indicate folder]:

[doc root]
-----[php]
---------- script.php
---------- [some folder]
--------------- [another folder]
-------------------- current.php

Let's then say that I want to include 'script.php' inside 'current.php'. As
it is now, I'm having to use include('../../script.php'). This is obviously
a nuisance, especially if I want to move things around. Now, I remember in
the past (different server config), using include('/php/script.php') would
work perfectly fine, but it does NOT work now, and I'd love for it to work.
Using /folder/file.ext works in regular HTML so I can only assume it is not
a problem with Apache. So my question is, is this simply a PHP config
problem?

PHP 4.3.4
Apache 1.3.something

Thanks!!!!!

Vinny


Jul 17 '05 #1
3 2145
Vinny wrote:
I don't know if this is a PHP config problem, or an Apache 1.3/PHP 4
problem, or what. When I include a script, say 2 folders up in the
structure, I'm having to move up to it instead of skipping to root and
moving down to it. Allow me to clarify, let's say my tree structure looks
like so [brackets indicate folder]:

[doc root]
-----[php]
---------- script.php
---------- [some folder]
--------------- [another folder]
-------------------- current.php

Let's then say that I want to include 'script.php' inside 'current.php'. As
it is now, I'm having to use include('../../script.php'). This is obviously
a nuisance, especially if I want to move things around. Now, I remember in
the past (different server config), using include('/php/script.php') would
work perfectly fine, but it does NOT work now, and I'd love for it to work.
Using /folder/file.ext works in regular HTML so I can only assume it is not
a problem with Apache. So my question is, is this simply a PHP config
problem?


look at your include_path

HTH
Bruno

Jul 17 '05 #2
Because include() use physical path and not your website root path (html).
You have to use the full physical path, something like
include("C:/wwwroot/user1/dom1/public_html/php/script.php") on windows or
include("/home/user1/dom1/public_html/php/script.php") on linux. But to be
simpler, you can also use the variable $_SERVER["DOCUMENT_ROOT"] which
return the physical up to your root.

include($_SERVER["DOCUMENT_ROOT"] . "/php/script.php");

Note: This is not a problem as this way, you can include any file everywhere
on the system (unprotected). Also it's also applied to ASP-VBS and others
languages.

Savut

"Vinny" <hc*******@yahoo.com> wrote in message
news:tQ*******************@newsread3.news.atl.eart hlink.net...
I don't know if this is a PHP config problem, or an Apache 1.3/PHP 4
problem, or what. When I include a script, say 2 folders up in the
structure, I'm having to move up to it instead of skipping to root and
moving down to it. Allow me to clarify, let's say my tree structure looks
like so [brackets indicate folder]:

[doc root]
-----[php]
---------- script.php
---------- [some folder]
--------------- [another folder]
-------------------- current.php

Let's then say that I want to include 'script.php' inside 'current.php'. As it is now, I'm having to use include('../../script.php'). This is obviously a nuisance, especially if I want to move things around. Now, I remember in the past (different server config), using include('/php/script.php') would
work perfectly fine, but it does NOT work now, and I'd love for it to work. Using /folder/file.ext works in regular HTML so I can only assume it is not a problem with Apache. So my question is, is this simply a PHP config
problem?

PHP 4.3.4
Apache 1.3.something

Thanks!!!!!

Vinny


Jul 17 '05 #3
thx, I'll start using that :)

"Savut" <we***@hotmail.com> wrote in message
news:DI*******************@news20.bellglobal.com.. .
Because include() use physical path and not your website root path (html).
You have to use the full physical path, something like
include("C:/wwwroot/user1/dom1/public_html/php/script.php") on windows or
include("/home/user1/dom1/public_html/php/script.php") on linux. But to be simpler, you can also use the variable $_SERVER["DOCUMENT_ROOT"] which
return the physical up to your root.

include($_SERVER["DOCUMENT_ROOT"] . "/php/script.php");

Note: This is not a problem as this way, you can include any file everywhere on the system (unprotected). Also it's also applied to ASP-VBS and others
languages.

Savut

Jul 17 '05 #4

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

Similar topics

2
by: pietlinden | last post by:
I have a hopefully stupid question. First off, I'm trying to follow Keri Hardwick's instructions from here: http://www.mvps.org/access/forms/frm0031.htm I have a main/sub1/sub-subform:...
21
by: Mark Rae | last post by:
Hi, Apologies if this is a stupid question - I'm a C# newbie... :-) I have a Windows app with two form: frmConfigReg and frmNewApp. frmConfigReg is the startup form. It has several controls,...
4
by: Danny Tuppeny | last post by:
Hi all, I've been trying to write some classes, so when I have a parent-child relationship, such as with Folders in my application, I don't have to remember to add a parent reference, as well as...
1
by: Brian P | last post by:
I have a class, Folder, that I want to hold a reference to its parent Folder as well as its subfolders. I'm using List<Folder> to hold its list of sub folders. What I want to do is when a...
4
by: MA | last post by:
Hi, How to access the total number of child nodes from a parent node. For example, I would like to get the total number of child nodes from <parent1and <parent2node. The SelectNodes method...
6
NeoPa
by: NeoPa | last post by:
Introduction The first thing to understand about Sub-Forms is that, to add a form onto another form takes a special Subform control. This Subform control acts as a container for the form that you...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
4
by: davin.pearson | last post by:
Here is my file index.php: <?php include "../parent.php"; ?> When I try to run this code on a Linux server, it gives me the following error message: Warning: main(): open_basedir...
0
by: alivip | last post by:
Is python provide search in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name camry and file name corola,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.