Reputation: 11
I am an amateur web developer and I am trying to get my site live for the first time. The site is working and all of the files are uploaded but the site is not loading my PHP includes.
Here is the error message:
Warning: include(includes/header.php) [function.include]: failed to open stream: No such file or directory in /home4/myUsername/public_html/index.php on line 3
How can I get PHP to look in public_html/
rather than public_html/index.php
?
EDIT: I have tried editing the include path. It doesn't seem to change where php is looking for the file. Additionally my includes work properly in localhost.
Upvotes: 1
Views: 1486
Reputation: 1177
I'm going to assume this is your folder structure:
Generally (not always), $_SERVER['DOCUMENT_ROOT'] will now reflect the path to the base public_html directory (this I'm assuming based on the context of your message). This means you can always point to the root this way. - no matter if you have /index.php or /my/deep/file/structure.php
Try this with your include statement on index.php
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php');
Upvotes: 2
Reputation: 7181
You may need to change the include path in your php.ini file or use set_include_path()
to change the include path.
Here is the manual entry for the function call if you'd like to read more about it.
Upvotes: 1
Reputation: 5
Have you checked already the include file?
in given. include(folder_includes/file_header.php);
Upvotes: 0