include not working

I don't get it 😦 I'm using include for every page to get my server and my header. But on one reason doesn't work on this page…
<?php
include './Includes/server.php';
include './Includes/header.php';
?>
// Rest of my code
<?php
include "./Includes/footer.php"
?>
<?php
include './Includes/server.php';
include './Includes/header.php';
?>
// Rest of my code
<?php
include "./Includes/footer.php"
?>
my folder structure for this file is: |-- assets/ | |-- css/ | |-- js/ | |-- images/ | |-- includes/ | |-- header.php | |-- footer.php | |-- server.php | |-- pages/ | |-- admin/ | |-- kruiske-online.php this is the file where it doesn't work | |-- settings.php | |-- home.php Is there anyone that knows how I can fix this? Ps. I got these error messeges: Warning: include(C:\xampp\htdocs\twt-app.dev\pages\admin../../Includes/server.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 2 Warning: include(): Failed opening 'C:\xampp\htdocs\twt-app.dev\pages\admin../../Includes/server.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 2 Warning: include(./Includes/header.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 3 Warning: include(): Failed opening './Includes/header.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 3 Warning: include(./Includes/footer.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 10 Warning: include(): Failed opening './Includes/footer.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\twt-app.dev\pages\admin\kruiske-online.php on line 10
9 Replies
Jochem
Jochem13mo ago
It's probably case sensitive Ah, and you're trying to include from ./,which is the current working directory, and that's not where the includes folder lives
Rianẍa
RianẍaOP13mo ago
But I have try every other path. ../ or even the whole path of my directory. And even that would not work?
Jochem
Jochem13mo ago
have you tried with a lower case i?
Rianẍa
RianẍaOP13mo ago
yes I tried but doesn't work
Jochem
Jochem13mo ago
if your folder structure is correct, the include should be include('../../includes/header.php');
Rianẍa
RianẍaOP13mo ago
It works! 😄 Thank you! Can I actually use this path for every file? Regardless of which folder it is in?
Jochem
Jochem13mo ago
no, that's a relative path. .. represents the parent folder, so that path will go two levels up, then into includes the alternative is an absolute path, which can be finnicky on windows too, and you also don't want to hard code that because you probably have a different path on your development machine than you do on production
Rianẍa
RianẍaOP13mo ago
okay then I know 🙂 Thanks! then I can continue
ἔρως
ἔρως13mo ago
instead of doing all that weird path traversal, you can use the $_SERVER['DOCUMENT_ROOT'] variable, or maybe store it in a constant ending with DIRECTORY_SEPARATOR appended to it
Want results from more Discord servers?
Add your server