doukezi4606 2013-03-19 11:14
浏览 32
已采纳

找不到PHP文件,但它就在那里

When I'm running my site it keeps telling me

Warning: require_once(../../functions.inc.php): failed to open stream: No such file or directory in F:\xampp\htdocs\FinalYear\inc\functions\LoginOrRegister.inc.php on line 5

But the file is exactly 2 folders above the file I'm requiring. When I'm doing the following:

set_include_path(dirname(__FILE__)."/../../");
require_once('functions.inc.php');

It works (I don't get an error message for a non-existing file BUT In the functions.inc.php there is a new object created of the database.php.

$db = new database();

I can call this on every other site, just not on my LoginOrRegister.php. It always tells me, that this object doesn't exist, even, when I create it myself in the file. Any help?

  • 写回答

3条回答 默认 最新

  • dsfdsf23423 2013-03-19 11:20
    关注

    It looks to me like you are including a file from an included file. If that is the case, the relative path has to be relative to the script that is running, and not the script that is included inside the first script.

    It is much easier to use absolute paths (use dirname(__FILE__) before the relative path).

    require_once(dirname(__FILE__)."/../../functions.inc.php");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?