php in html - problem

Discussion in 'HTML & Website Design' started by PATRICIA NSON, Apr 12, 2012.

  1. #1
    Hi,

    I have a website which runs primarily on html, but I call some dynamic content using <?php include 'list.php' ?> inside the body tag of index.html.

    <html>
    ....
    <body>
    ....
    <?php include 'list.php' ; ?>
    ...
    </body>
    </html>

    The domain is redirected to public_html/myproject (index.html and list.php is present here). Now only the html shows up. The php content is not included. (the list does not show up, works fine in local machine) How do I include php on html files?

    What changes should I make?
    1. I tried adding a .htaccess in the myproject folder with the content

    AddType application/x-httpd-php5 .html .php
    AddHandler application/x-httpd-php5 .html

    But it throws a 500 error.

    2. Should I make any changes to php.ini file? [ There is no php.ini file in the sub directory as of now. Is it required? ]

    3. I also tried adding a apache handler in the bluehost control panel, but in vain.

    Desperately in need of a solution. Appreciate any quick response, Thanks
     
    PATRICIA NSON, Apr 12, 2012 IP
  2. MarPlo

    MarPlo Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    48
    #2
    Hi,
    Try replace the ".html" extensionn with ".php" ( to have "index.php"), in this way the file is processed by PHP server.
     
    MarPlo, Apr 12, 2012 IP
  3. traxport121

    traxport121 Active Member

    Messages:
    1,201
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    63
    #3
    Well MarPlo is right, you cannot insert php into html BUT you can insert html into php.
    So rename your file / change its extension from ".html" to ".php" then if you insert the php code as you have shown above it work :)
     
    traxport121, Apr 12, 2012 IP