Jump to content

Recommended Posts

I know including a file isn't very hard but for some reason it's not working. 

 

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

 

I KNOW that's where the file is but I get the error

 

Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

and

 

Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem.

 

Example of another page I include the same file in

 

include ("admin/config.php");

 

This works perfectly  ???

 

Any help would be greatly appreciated, thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/86943-help-with-includeing-a-file/
Share on other sites

I know including a file isn't very hard but for some reason it's not working. 

 

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

 

I KNOW that's where the file is but I get the error

 

Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

and

 

Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem.

 

Example of another page I include the same file in

 

include ("admin/config.php");

 

This works perfectly  ???

 

Any help would be greatly appreciated, thanks in advance!

 

Actually what could help you is:

 

include(../admin/config.php); ---- loose the ../ and put
include ("admin/config.php"); - this sould be fine

 

When you are using ../ you are going one dir back. And if you are in current dir and want to access admin/config.php, then you do as above.

I know including a file isn't very hard but for some reason it's not working. 

 

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

 

I KNOW that's where the file is but I get the error

 

Warning: include(../admin/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

and

 

Warning: include() [function.include]: Failed opening '../admin/config.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\www\trade\includes\search.php on line 3

 

The same file includes in other pages just fine but I don't go more than one folder deep and I was thinking that might be the problem.

 

Example of another page I include the same file in

 

include ("admin/config.php");

 

This works perfectly  ???

 

Any help would be greatly appreciated, thanks in advance!

 

Actually what could help you is:

 

include(../admin/config.php); ---- loose the ../ and put
include ("admin/config.php"); - this sould be fine

 

When you are using ../ you are going one dir back. And if you are in current dir and want to access admin/config.php, then you do as above.

 

Thanks!

 

I was trying to go up one folder that's why I added the ../ , I guess I didn't need to do that.

I struggled with this for a LONG TIME before I realized calling includes like this works no matter where your at in the file structure..

 

include($_SERVER['DOCUMENT_ROOT'].'/path/to/the/file.php');

 

 

This will start at the servers doc root and find the file that way. It works for me every time without problem.

 

 

Hope this helps,

 

Nate

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.