Page 1 of 1

Include function not working on remote site

Posted: Tue May 27, 2003 4:57 am
by GeorgeF
Hi

I am having a bit of a nightmare with the INCLUDE function.

I have created Header and Footer files called: header.inc and footer.inc both stored in a directory called includes.

The above files have straight forward HTML within them

On every HTML page within my site I have the statements:

<html>
<body>

Html tags etc..

<?php
include("includes/header.inc");
?>

More Html stuff


<?php
include("includes/footer.inc");
?>

</body>
</html>

On my development PC at home I run this and everything works prefectly. However, once I upload the files to my site and launch, I Get the HTML output, but not the output for my header or footer

I viewed the source and I notice that the PHP code is displayed as written above and not rendered to the contents of the header and footer.



Can anyone help please :(

Posted: Tue May 27, 2003 5:02 am
by twigletmac
Is PHP installed on the remote server? Do you get anything if you upload a script containing:

Code: Select all

<?php
phpinfo();
?>
and view it.

Mac

Yes PHP is running on the remote site

Posted: Tue May 27, 2003 5:08 am
by GeorgeF
I also have a PHPBB forum on my site and this works fine

Posted: Tue May 27, 2003 5:10 am
by Rob_Beard
George, close your PHP tags:

<?

?>

Also, put semicolons after your php commands:

include("file.inc");

cheers

Rob

Posted: Tue May 27, 2003 5:16 am
by GeorgeF
Sorry about this but in the site pages I have closed the tags and the semi colon is present.

I neglected to put them in the above original post.

So the original question remains. Oh dear. I'm sure it has to be something about pathing and root but I don't know where to start looking.

Posted: Tue May 27, 2003 5:21 am
by Rob_Beard
Sorry for the simplicity of this, and i'm sure you have already considered it, but;
Did you name that file with a .php extension? or .php3?
(file.php, file.php3)?

Posted: Tue May 27, 2003 5:26 am
by GeorgeF
All the calling files have an .htm extension. I am 'Including' the header.inc and footer.inc in these files with the php code snippets as shown in the original post shown above.

Posted: Tue May 27, 2003 5:57 am
by twigletmac
The server is probably not setup to see .htm files as PHP - most likely you will need to rename your files with .php extensions in order to have the PHP code execute.

Mac

Posted: Tue May 27, 2003 6:03 am
by GeorgeF
Thanks I'll give it a go when I get home tonight.

Otherwise 'I'll be baaaaack!' :wink:

I have found the solution

Posted: Wed May 28, 2003 4:21 am
by GeorgeF
I have discovered that if the server settings to parse .htm files for PHP statements is not set, then the PHP code within these

files is disregarded and is treated like a comment within the html code.

For the php statements to work, you either turn this setting on at the server, which I understand is the default, however this

may produce more overhead for the server so many ISP's may turn this feature off. As a workaround, I have renamed all my

.htm files and links with the extension of .php and this now works.

'The problem is simple, it's the solution that's hard' :lol: