Page 1 of 1

[solved] dot dot slash

Posted: Sun Apr 18, 2004 6:56 am
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?

Posted: Sun Apr 18, 2004 7:00 am
by mudkicker
../ is the root directory i think

Posted: Sun Apr 18, 2004 7:09 am
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.

Posted: Sun Apr 18, 2004 7:12 am
by Dale
Your missing a ; at the end of your include tag.

Code: Select all

<?php
include("../afile.php");
?>

Posted: Sun Apr 18, 2004 7:17 am
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.

Posted: Sun Apr 18, 2004 7:21 am
by feyd
../ is one level up.

Posted: Sun Apr 18, 2004 7:25 am
by Dale
Gen-ik wrote:The ; is optional for single line commands.


oh... never knew that...

Posted: Sun Apr 18, 2004 7:31 am
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...

Posted: Sun Apr 18, 2004 9:13 am
by vigge89
never knew "/" was the root, so would this work then?

Code: Select all

<?php
include ('/folder/file.php');
?>
?

Posted: Sun Apr 18, 2004 9:51 am
by Gen-ik
I've sorted it out. I had to edit something in the Apache conf file.

Thanks.

Posted: Sun Apr 18, 2004 5:06 pm
by Dale
I never use just / i only use ./ (Thats how i was learnt it)