doukezi4606 2013-03-19 03: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 03: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 vue但是页面显示的数据为空为什么呀,明明在钩子函数中已经成功赋值(相关搜索:输出数据)
  • ¥15 syri可视化不显示插入缺失
  • ¥30 运行软件卡死查看系统日志分析不出来
  • ¥15 C语言代码改正特征选择算法设计,贝叶斯决策,,设计分类器,远程操作代码修正一下
  • ¥15 String 类valuve指向的问题
  • ¥15 在ros2的iron版本进行编译时遇到如下问题
  • ¥18 vs用setup project打包项目实现安装完立即运行
  • ¥15 孟德尔随机化TwoSampleMR在线提取结局数据,遇到Error in check_reset(override_429)的问题
  • ¥15 ONNX转RKNN遇到问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部