SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is probably a dumb question. Is there a way to use php on a html page? I want use include and pass a variable, but it would be very helpfull to be able to do it on a html page.
    Of course it works fine for me on a php page, say index.php
    But it does not work on index.html. I would guess it is because you have to tell the server, this is a php page.

    Is there a way to do this? The reason I would like this to work is that I have many older pages, all html that I would like to use include to update, long story. Anyways an example of the include:

    index.php

    <?php

    $site_no="1234";

    include ("http://someserver/somefile.inc.php");

    ?>

    Somefile:

    <?php

    echo "This is site #$site_no";

    ?>

    Of course this works fine if the file I try to include it to has the extesion of php. Can I do it had was index.html??

    Thanks.

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup.. it's very easy... I just added this to my site because I had some old .html files that needed to be parsed by php

    add this to your .htaccess file in your home dir (the one with the index.* file in it....

    Code:
    AddType text/x-server-parsed-php .html
    So there! It's that simple! PHP now will parse *.html files!However, if you use SSI on your *.htnl files then you need to remove this line from your .htaccess file:

    Code:
    AddType text/x-server-parsed-html .html
    Because the server don't like doing both at the same time... just replace your <!--#blah--> with

    PHP Code:
    <?php
    include "filedir/file.ext";
    ?>
    It does the same job.... and from now on, just forget using SSI on *.html files... use PHP! Also, as you can figure you could set PHP to parse whatever files you wanted it to... but don't have it do *.cgi, *.pl, *.shtml, *.ssi, *.cfm, or any other pre-set serverside language that you have not configured with the .htaccess file... it will cause problems...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What server are you using

    Apache instructions:
    If you have access to the httpd.conf file simply find the line that says AddType application/x-httpd-php4 .php .phtml and *** .html to the end of it

    Or on a per directory basis create a file named .htaccess and put this line it and stick it in the folder where you want to parse .html as php

    AddType application/x-httpd-php4 .html





    Let me know if you are using some other web server
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Freddy And Exbabylon!

    I use .htaccess some right now, so this would be a perfect solution. I was thinking that could work, or thought I had read it some where. Course I was'nt sure what to put into the file to make it work.

    I'm pretty sure my domains are on apache. Sounds bad that I don't know, but hey, thats why I pay for hosting..hehehehe

    One question exbabylon, I've seen the code freddy suggested, but yours is different, what is it x-server?

    AddType text/x-server-parsed-php .html

    Just kinda new to me,course what is'nt..

    Thanks again!

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  5. #5
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tried adding

    AddType application/x-httpd-php .html

    to my htaccess and it worked perfect! My include came up and actually with alot of html code and it came up pretty fast.

    Thanks again!

    P.S. Does any one know of any good .htaccess info? There seems to be a lot you can do with it. I know apache provides all the information, but does any one know of plain english, maybe tutorials?

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try http://www.internet-tips.net/Webmaster/htaccess.htm it is written so that the rest of us can understand it !

    Sean

  7. #7
    SitePoint Enthusiast Jujubee's Avatar
    Join Date
    Mar 2001
    Location
    Canada
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Neat trick! But is there any disadvantage to doing this? Any potential complications?

    Thanks.

  8. #8
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not really... just that SSI won't work on *.html pages if you set SSI to parse those...
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  9. #9
    SitePoint Addict
    Join Date
    Jul 2000
    Location
    North Central AR
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The advantage, like in my case. I have many older html pages that if I changed to .php, they would'nt be the same pages, say for pages that are in the SE's.. So you can still use the wonderfully world of php on those pages.

    Course this is something I just learned thanks to all the helpfull people here..

    ronnie
    The largest selection of PLR Articles on the Planet!
    Many Private Label Rights Products.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •