0

My directory is set up like this:

htdocs/
 globe_bank/
   private/
    shared/
     staff_header
   public/
    staff/
     index.php

I am trying to include both the staff_footer and staff_header files within my staff\index.php file.

<?php include('../../private/shared/staff_header'); ?>

However, I am getting the following error:

"Warning: include(../..private/shared/staff_header): Failed to open stream: No such file or directory in C:\xampp\htdocs\globe_bank\public\staff\index.php on line 3

Warning: include(): Failed opening '../..private/shared/staff_header' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\globe_bank\public\staff\index.php on line 3"

Any ideas on how to fix this?

Phil
  • 157,677
  • 23
  • 242
  • 245
  • 3
    Are you missing the file extension? Eg `staff_header.php`. I also highly recommend prefixing the path with `__DIR__` to ensure it is relative to the current script, ie `include __DIR__ . '/../../private/shared/staff_header.php';` – Phil Jun 17 '22 at 00:35
  • 1
    Your include_path doesn't contains `.` so it won't look in current directory when working on relative paths. That looks like a misconfiguration to me. Use `__DIR__` to start at the current directory then either use dirname() to go up a level, or follow up with `/..` for each level you want to go up towards the root. – Kevin Y Jun 17 '22 at 00:41
  • unfortunately adding __DIR__ before the path didn't solve anything. Still looking for fixes. – BlazeCobalt Jun 20 '22 at 23:16
  • Is `staff_header` a file that actually exists? If so, why does it not have a file extension? Please also [edit] your question to show the code you're now using and the current error message – Phil Jun 20 '22 at 23:40

0 Answers0