Results 1 to 9 of 9
  1. #1
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    I have written a PHP script named dynamic.php. It runs fine by itself, I have been trying to insert it into a index.htm file, the site root page. For some reason the code does not get parsed, what am I doing wrong?

  2. #2
    Full Member jollygoodpirate's Avatar
    Join Date
    January 18th, 2005
    Location
    NC
    Posts
    227
    First make sure php is available for your host.
    Then make sure your php code is enclosed in
    <? ?>

    Assuming these, your webserver is probably only configured to see php code if the extension of the file is .php

    you have two choices, change your file's extension to .php or you can tell the webserver to treat .htm files as if they are .php files. In order to do that add this to your server configuration file:

    AddType application/x-httpd-php .php .html .htm

    That should fix it.

  3. #3
    Member
    Join Date
    January 18th, 2005
    Posts
    148
    I don't think you can use php in html. I think you'll need to convert your index page into php.

    ATKOgirl

  4. #4
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    Jolly, can that AddType statement be put into .htaccess or does it have to go into the config file?

    Jim

  5. #5
    Member
    Join Date
    January 18th, 2005
    Posts
    103
    You can put it in your .htaccess.

    I use PHP scripts on all my old htm pages with this.

  6. #6
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    You can also enclose the php output in a client-pulled section of the page using an iframe or javascript.

    In this case, you wouldn't need to change the mime type.
    “An adventure is an inconvenience rightly considered. An inconvenience is an adventure wrongly considered.” - G.K. Chesterton

  7. #7
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    As far as .htaccess, is this something I can install or would my hosting company have to do this? I tried to run a search here read postings but the search function does not work

  8. #8
    ABW Ambassador cditty's Avatar
    Join Date
    January 18th, 2005
    Location
    Memphis TN
    Posts
    1,434
    Have you tried calling your php file via an ssi include? If memory serves correctly, this will execute the php file and include it in the htm page.

    Chris
    Recycled Talent - Architects of custom scripts and snippets, perfectly written to suit any need. We stay on top of the latest technology so you don't have to.
    Total Stupidity - Shining light on stupid things.

  9. #9
    Full Member
    Join Date
    January 18th, 2005
    Posts
    379
    Most hosts allow you to add your own .htaccess
    Check your hosts support forums or FAQs.

    Remember that once you upload the file you may not be able to view it in your FTP clients. I like to use my cpanel file manager to modify my .htacess files

    There are some host that allow you to add certain directive with a form in CPanel.

    Like others have nmentioned I have used my .htaccess file to run php on a .html

  10. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Using PHP (or JS) on .htm or .html pages
    By webworker in forum PopShops
    Replies: 42
    Last Post: September 18th, 2011, 12:09 PM
  2. Php Script to Download Web File Not Working
    By Uncle Rico in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: January 19th, 2009, 01:11 PM
  3. Runing PHP code in a htm page
    By websmith in forum Programming / Datafeeds / Tools
    Replies: 6
    Last Post: July 11th, 2008, 07:40 PM
  4. PHP Script to convert vidio file into FLV
    By rahulcbr in forum Programming / Datafeeds / Tools
    Replies: 12
    Last Post: April 28th, 2008, 09:31 AM
  5. Why? "Can't write to file xxxx.htm"
    By buy_online in forum WebMerge (Fourthworld.com)
    Replies: 9
    Last Post: December 6th, 2003, 02:39 PM

Posting Permissions

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