[solved] dot dot slash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

[solved] dot dot slash

Post by Gen-ik »

This has been buggin' me for a while but I've managed to work around it easy enough, and as I was passing by thought I might ask you guys 'n gals about it.

If I try to include() or require() a file which is in a higher directory I always get an error saying that the file can not be found. An example would be..

Code: Select all

<?php include("../afile.php") ?>
..and even though the file is there PHP doesn't seem to be able to see it.

Any ideas?
Last edited by Gen-ik on Sun Apr 18, 2004 9:53 am, edited 1 time in total.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

../ is the root directory i think
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Hmm.. ok, so what would "one level up" be? In HTML, CSS, and JS "../" is used to point to a directory one level up and a simple "/" is used for the root directory.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Your missing a ; at the end of your include tag.

Code: Select all

<?php
include("../afile.php");
?>
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Dale wrote:Your missing a ; at the end of your include tag.

Code: Select all

<?php
include("../afile.php");
?>
The ; is optional for single line commands.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

../ is one level up.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Gen-ik wrote:The ; is optional for single line commands.


oh... never knew that...
hughr
Forum Newbie
Posts: 3
Joined: Sun Apr 18, 2004 7:31 am
Location: G.D.CHINA

Post by hughr »

/ -- root directory
. -- current directory
.. -- parent directory
; -- is NOT optional (or CAN but i dont know)
I -- dont know what 's happening with this problem...
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

never knew "/" was the root, so would this work then?

Code: Select all

<?php
include ('/folder/file.php');
?>
?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

I've sorted it out. I had to edit something in the Apache conf file.

Thanks.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

I never use just / i only use ./ (Thats how i was learnt it)
Post Reply