Include function not working on remote site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

Include function not working on remote site

Post 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 :(
Last edited by GeorgeF on Tue May 27, 2003 5:18 am, edited 1 time in total.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

Yes PHP is running on the remote site

Post by GeorgeF »

I also have a PHPBB forum on my site and this works fine
Rob_Beard
Forum Newbie
Posts: 23
Joined: Sat Oct 12, 2002 11:58 am

Post by Rob_Beard »

George, close your PHP tags:

<?

?>

Also, put semicolons after your php commands:

include("file.inc");

cheers

Rob
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

Post 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.
Rob_Beard
Forum Newbie
Posts: 23
Joined: Sat Oct 12, 2002 11:58 am

Post 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)?
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

Post by GeorgeF »

Thanks I'll give it a go when I get home tonight.

Otherwise 'I'll be baaaaack!' :wink:
User avatar
GeorgeF
Forum Newbie
Posts: 10
Joined: Tue May 27, 2003 4:57 am
Location: Ash Hampshire

I have found the solution

Post 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:
Post Reply