Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Includes in a .html extension
Old 08-14-2008, 07:06 PM Includes in a .html extension
TreyeMe's Avatar
Experienced Talker

Posts: 49
Name: Mike
Location: NY
Trades: 0
So i was wondering how to use includes in a .html file

Im having trouble even using includes accually in a .php file but im sure Ill figure that out.

anyway I was wondering how to make it so that the server realizes that some .html files may contain php or so on....I know it has something to do with the .htaccess file but Im not sure what I need to add to it/change it/save it/or even upload it....I know it needs to be transfered as an ASCII file or atleast believe it needs to be.

Any tutorial links or advice would be greatly aprieciated.

Thanks,
TreyeMe
TreyeMe is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-14-2008, 07:38 PM Re: Includes in a .html extension
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
Put this in your root htaccess file. It should work, I've never tested it:

AddType application/x-httpd-php .html
bill benson is offline
Reply With Quote
View Public Profile
 
Old 08-14-2008, 08:59 PM Re: Includes in a .html extension
Novice Talker

Posts: 6
Name: Jeff Hunt
Trades: 0
Depends on what your trying to do. If you just want to include it, you can do as he has said.. If you want to use "Template" files then you should have it READ that file and then have it set that whole file to a variable.. Once thats done, just do an str_replace with the file of the variables in the html template file you want to replace.. So lets say in your HTML file you want to replace {username} with the users name.. just doa str replace that replaces {username} with the correct string. Simple as that

Enjoy

Shimmy
__________________
Win prizes by putting your pic up and letting people tag it!
Please login or register to view this content. Registration is FREE

ShimmyShine is offline
Reply With Quote
View Public Profile Visit ShimmyShine's homepage!
 
Old 08-16-2008, 10:40 AM Re: Includes in a .html extension
TreyeMe's Avatar
Experienced Talker

Posts: 49
Name: Mike
Location: NY
Trades: 0
I just want to use basic html such as my links menu and head and other basics on other pages so that if I ever change or add a link it will be convient.


Bill Benson:

I tried added that bit of information to my htaccess file but it did not help

Ive also tried making the maing page .php even and it still will not open the include file and I am even using an absolute address to call the include file into the script.

Ive also made the main page .phtml .htm .html .php and even tried vierities of the others as a long shot for the include file even.

I even tried simple ASP although Ive never honestly used php or ASP before.

Any other suggestions or ideas would be greatly aprieciated

Thanks,
TreyeMe
TreyeMe is offline
Reply With Quote
View Public Profile
 
Old 08-16-2008, 10:43 AM Re: Includes in a .html extension
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
So i was wondering how to use includes in a .html file
Apache server or IIS server?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-16-2008, 10:51 AM Re: Includes in a .html extension
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Code:
AddType application/x-httpd-php .html
does work, as outlined above. I have used it when converting a large static site to use dynamic elements, because I didn't want to rename every .html page with a .php extension.

TreyeMe, you haven't posted any code that you have attempted, so you don't give us much of a clue as to what you could be doing wrong. Includes are very easy in a .php file, with a server that has PHP enabled, and works like this:
PHP Code:
<?php include "path/to/file.php"?>
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-16-2008, 10:57 AM Re: Includes in a .html extension
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
.htaccess
Code:
AddType text/html .htm .html .shtm .shtml
AddHandler server-parsed .htm .html .shtm .shtml
Options Indexes FollowSymLinks Includes
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-16-2008, 11:43 PM Re: Includes in a .html extension
TreyeMe's Avatar
Experienced Talker

Posts: 49
Name: Mike
Location: NY
Trades: 0
My host does support PHP

the code is straight forward but if you would like it here it is.

Also I contacted my hosting company and they are telling me it is on my end within the code...but wont tell me where what or however. Ussually they are a lot more helpful than this. I guess i got some one having a bad night or something.

ALSO - When i copied and pasted that code into my htaccess file and saved it. It was giving me page not found errors. So i took the last line out of the file and the pages started showing up again. Not with the php includes but just as before.......

Anyway here is the code:

PHP Code:
 <div id="menutop">
<?php include "http://eveotto.com/topnav.html"?> 
</div>
I have also tried

PHP Code:
 <div id="menutop">
<?php include ("http://eveotto.com/topnav.html"); ?> 
</div>
does not make any sense to me...

The page sound look like

Http://eveotto.com

the page I am trying to get the includes to work on is:

Http://eveotto.com/test.html

and the page I am trying to include is:

Http://eveotto.com/topnav.html


~
TreyeMe
TreyeMe is offline
Reply With Quote
View Public Profile
 
Old 08-17-2008, 06:40 AM Re: Includes in a .html extension
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
My host does support PHP
Sure but is it Apache or IIS?

the .htaccess code I posted is for server side includes (SSI) in .htm(l) NOT for PHP in .htm(l). For that you need to use Abel's code (wayfarer07).

does the include work when used in a file with a .php extension?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-17-2008, 09:24 AM Re: Includes in a .html extension
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I'm not 100% sure about this, but it may be possible that if the allow_url_fopen directive in your php.ini file is not set to on, you may not be able to preface your includes with "http://yourwebsiteaddress.com/", even though your are doing so from your own server. Some hosts have this disabled by default. Try making your paths relative to the document instead, like:
PHP Code:
include "topnav.html"
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 08-17-2008, 10:38 AM Re: Includes in a .html extension
TreyeMe's Avatar
Experienced Talker

Posts: 49
Name: Mike
Location: NY
Trades: 0
AMAZING!

I honestly thought that an absolute path to the include file would demand only that file excluding any chances of it being wrong.

Thanks So Much Guys. MUCH HELP!
TreyeMe is offline
Reply With Quote
View Public Profile
 
Old 08-17-2008, 02:17 PM Re: Includes in a .html extension
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
When I need an absolute path in PHP, I specify it from the document root, like this:
PHP Code:
include $_SERVER["DOCUMENT_ROOT"]."file.php"
What this does is start at the base of the file system, and work its way up to the root of your website. To see what this and other superglobals look like, make a page called test.php, then toggle the server info like this:
PHP Code:
<body>
<?php phpinfo(); ?>
</body>
Scroll to the bottom of the page to see all of the super-globals as they apply to your site and page.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-31-2008, 12:52 AM Re: Includes in a .html extension
TreyeMe's Avatar
Experienced Talker

Posts: 49
Name: Mike
Location: NY
Trades: 0
Alright Ive been at this for a while and tired of playing around with this

I knew I posted here about this before so ill just ad to this thread. sorry to bring up an old topic.

ANYWAY here are the links

http://treyedesigns.com

and this is how I would like it

http://treyedesigns.com/test.html

I cant get the includes to work properly any ideas Ive tried every different way you could write it upload it save it....how ever I cant figure this out. I even went back and copied and pasted code from previous work --_--

ALSO as a side what does everyone think of the layout so far as the design - colors - and so on

Thanks,
TreyeMe
TreyeMe is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Includes in a .html extension
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38082 seconds with 12 queries