views:

36

answers:

2

Web page contains php includes:

<?php
  include 'http://www.example.com/header.txt';
?> 

and

<?php
  include 'http://www.example.com/footer.txt';
?>

header.txt and footer.txt files with html markup are placed in the root folder of a website.

Everything went ok pretty long, but suddenly the following error messages appeared on webpages in browser right after markup areas, incerted by these php scripts:

Warning: Unknown(includes/main.php): failed to open stream: No such file or directory in >Unknown on line 0

Warning: Unknown(includes/main.php): failed to open stream: No such file or directory in >Unknown on line 0

Warning: (null)(): Failed opening 'includes/main.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in Unknown on line 0

All markup from txt files is shown by browser correctly. The only problem are these Warning messages. Site is hosted on shared hosting. Nothing was changed in the content of web site folder before these messages appeared.

What is the problem?

+2  A: 

You are using the site url to include the files which is not ideal and depends on php settings eg allow_url_fopen; it won't work either if you move your site to some different domain. Try using relative paths instead, example:

include 'includes/header.txt';
Sarfraz
A: 

use include_once.

use ob_flush at the line 0

zod