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条)

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?