Jump to content

PHP including a file from a different directory?


Platypus

Recommended Posts

I tried including a PHP file from a different directory...

 

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

 

Normal PHP includes work, however I cant get it to work if the file im trying to include is in a diff directory. Its in /forums/

 

Warning: include(../news.php) [function.include]: failed to open stream: No such file or directory in /home/user/public_html/index.php on line 150

 

Warning: include() [function.include]: Failed opening '../news.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/index.php on line 150

 

In need of assistance.

Link to comment
Share on other sites

Your problem is probably not having the correct relative path to your include file."

 

Try adding the directory name to your path the include file is in.

 

<?php include("../files/news.php");?>

 

Or if your still confused just use the full path like this:

 

<?php

include("/home/byron/public_html/php/tools/sweeper.php");

?>

 

 

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...