hi
i have some file in my ftp.now i am saving my file in a folder.please tell me how to refer the file outside the folder.
eg require_once('../common/dblayer.php');
the above is to refer a file inside a folder.how do the same for outside a folder

What do you meen by saing "Outside of the folder". Because the example you gave shows everything you need to know to include/require a file. The ../ goes up one directory then the common/ goes down to the common directory then opens the dblayer.php.
That simple. So is there anything I am missing?

from dblayer.php i want to refer a file which is outside common.

in our server all files are stored in public_html
in that I HAVE MANY FILES AND FOLDERS.common is one among them.now from common i want to refer a file in public_html

to refer a file

That's the bit I don't exactly understand because I speak australian and to me would seem like to program one file to give another file directions to a location.
So say your file structure was the following:

public_html
    - folder1
    - common
    - folder3

Then to get from common the index.php in public_html you would use the following:

include("../index.php");

Is that what you are talking about or have I misunderstood again.

ya u r right.wat i am asking is

public_html(xyz.php)
- folder1
- common (dblayer.php)
- folder3
my dblayer.php is inside common.i have file which are in public_html but they are not in any folder .in that case how will u refer a file in main directory

In your dblayer.php, echo current working directory. Depending on which directory you are in, you can use ../ to go back one step to previous directory, ../../ to go back 2 steps and so on..
ie., If the file is in public_html/common/dblayer.php , using ../ will take you to the folder common and ../../ will take you to public_html :)
Your question raises more questions than answers !

Warning: include_once(./common/dblayer.php) [function.include-once]: failed to open stream: No such file or directory in /home1/careergl/public_html/converters.php on line 8

Warning: include_once() [function.include]: Failed opening './common/dblayer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/careergl/public_html/converters.php on line 8

Warning: include_once(./common/dblayer.php) [function.include-once]: failed to open stream: No such file or directory in /home1/careergl/public_html/converters.php on line 8

Warning: include_once() [function.include]: Failed opening './common/dblayer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/careergl/public_html/converters.php on line 8

  1. filenames are quoted include_once('./common/dblayer.php');
  2. count the dots . and .. are not the same
  3. Ensure the file is where you think it is relative to the calling file
This article has been dead for over six months. Start a new discussion instead.