/    Sign up×
Community /Pin to ProfileBookmark

include path to another folder

I am having trouble finding the correct path to my php file using include. The structure of the site is
www
site include
req.php file.php

I have the following code in the req.php file

[code]
include(‘../include/file.php’)
[/code]

it does not work; but the following href it works

[code]
<link rel=”stylesheet” type=”text/css” href=”../include/js23.css”>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@TyeMJan 25.2008 — If you are in site root and you want to reference a sub-directory where you are now use './' if you need to reference a directory one level above where you are calling from use '../'. Hope that makes sense.
Copy linkTweet thisAlerts:
@NogDogJan 25.2008 — To avoid confusion due to includes within includes, relocating files, etc., I'd recommend either (a) configuring your include_path setting to point to your includes directory, allowing you to just include files by name, or (b) using an absolute path such as:
[code=php]
// include directory at same level as web document root:
include $_SERVER['DOCUMENT_ROOT'] . '../include/file.php';

// include directory is a sub-directory of the web document root:
include $_SERVER['DOCUMENT_ROOT'] . '/include/file.php';
[/code]
Copy linkTweet thisAlerts:
@a_g_r_cJan 25.2008 — The hard way of checking would be to open your file in a browser....

Cut off the location you need....

Yuk thats horrible infact - Dont do that.

^^
×

Success!

Help @cedtech31 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...