0

Possible Duplicate:
PHP: Warning: include failed to open stream no such file or directory on Windows

My main folder is play. It contains config.php and login folder

login folder has a sub folder called ckeditor and it contains sub folder _samples. It has my php file selectnew.php

I want to include config.php to selectnew.php.

I have set path as follows:

include('play\config.php');

also I have tried

include('play/config.php');

but the following error is the result:

Warning: include(play/config.php) [function.include]: failed to open stream: No such file or directory in D:\wamp\www\play\logins\ckeditor\_samples\selectnew.php on line 7

Warning: include() [function.include]: Failed opening 'play/config.php' for inclusion (include_path='.;C:\php5\pear') in D:\wamp\www\play\logins\ckeditor\_samples\selectnew.php on line 7

my folders

play  folder
    --config.php
   logins folder
      ckeditor  folder
              _samples folder
           selectnew.php
Community
  • 1
  • 1
master3w
  • 71
  • 1
  • 11

2 Answers2

3

You have to go 2 folders up from your current directory (assuming your _samples contains your selectnew.php)

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

..or you can use this approach to traverse from root folder

include($_SERVER['DOCUMENT_ROOT']."config.php");

By the way you code doesn't work because you are using relative path to your current file directory. So basically, when you do include("play/config.php") the code will try to include this file

play/ckeditor/_samples/play/config.php

which doesn't existed.

Infinity
  • 3,695
  • 2
  • 27
  • 35
2

Going by this path D:\wamp\www\play\logins\ckeditor\_samples\selectnew.php, you should use

include('../../config.php');

The ../ goes back a step. So if you go back two times, you'll be in the play folder.

asprin
  • 9,579
  • 12
  • 66
  • 119