1

I have asked a question leading up to this earlier. Thanks again for your help.

  • I have updated my .htaccess file in my root directory with the following:

    AddType application/x-httpd-php .html

  • Where within my .html page should I place the php tag?,

I still cannot seem to get my .html page to load the .php script.

Community
  • 1
  • 1
HoustonGuy
  • 167
  • 1
  • 1
  • 8
  • You need to create `php` file and that should be run under apache server. – Krish R Dec 11 '13 at 07:06
  • 1
    Do you have a server running? – Shomz Dec 11 '13 at 07:06
  • what is the extention of ur page that u have created with the php code... – dhpratik Dec 11 '13 at 07:07
  • @Shomz - I'm somewhat a novice. I use godaddy, but modified my .htaccess according to this guide that someone else provided for me: http://php.about.com/od/advancedphp/p/html_php.htm – HoustonGuy Dec 11 '13 at 07:08
  • 1
    @dhpratik My website has all .html pages, and rather than updating everything to .php and breaking any existing links, it was suggested that I modify my .htaccess (like this link suggests http://php.about.com/od/advancedphp/p/html_php.htm) ... however, I have done so, but still cannot get the php to fire on my .html page, so I am assuming I am placing the tag in the wrong place? – HoustonGuy Dec 11 '13 at 07:10
  • Do you mind providing a live link of any page? Is your page extension .htm maybe? – Shomz Dec 11 '13 at 07:17
  • @Shomz If you look at http://mudchallenger.com/index.php you will see the php fire when you move your mouse like you're leaving the website. However, the same http://mudchallenger.com/index.html will not work. Any ideas? – HoustonGuy Dec 11 '13 at 07:23
  • What do you mean like leaving the website, you mean that popup is missing? If there's PHP on your HTML page, it's definitely rendered! – Shomz Dec 11 '13 at 07:25
  • @Shomz - The .php version of the page renders perfectly, however the .html version of the page does not render the php. The php script calls up a lightbox when your mouse breaks the browser plane, it's a last attempt to keep people on the site. – HoustonGuy Dec 11 '13 at 07:27
  • And what's your code to call and render that popup? I mean the original php code, not what's rendered as HTML. – Shomz Dec 11 '13 at 07:28
  • Hmmm, that looks fine, what happens if you change it to: ``, does it load the page then? – Shomz Dec 11 '13 at 07:33
  • @Shomz Unfortunately no. Nothing changed. – HoustonGuy Dec 11 '13 at 07:39
  • That is useful, you might want to edit your question and put that info there. One last shot from me: what happens if you leave only the `AddType application/x-httpd-php .html` in your .htaccess and remove everything else? – Shomz Dec 11 '13 at 07:43
  • @Shomz Is it safe to do that? I read elsewhere that could mess up other things? – HoustonGuy Dec 11 '13 at 08:08
  • Does it work like that? It's basically just telling the server to parse .html files as PHP. – Shomz Dec 11 '13 at 08:20
  • 1
    @Shomz --- thanks for the info. I called godaddy and I had modified the .htaccess file in the wrong folder and did not notice. Everything is good now. Thank you! www.mudchallenger.com/index-test2.html ... seems to work, now to just build out some type of a submission form. Thanks again. – HoustonGuy Dec 11 '13 at 17:08

2 Answers2

0

Where within my .html page should I place the php tag?

The answer is you can place your php content anywhere in your html page as long as it is inside <?php ?> tag.

even if you have done correct modification to .htaccess file and still your php content is not getting parsed than check whether you are connected to server or not.

R R
  • 2,999
  • 2
  • 24
  • 42
0

If you have followed this guide correctly, then according to the article, you should be able to execute php by simply opening a php tag.

From the article:

Things to watch out for:

  • If you have an existing .htaccess file, add this to it, do not overwrite it or other >settings may stop working! Always be very careful with your .htaccess file and ask your >host if you need help
  • Anything in your .html files that starts with your file for some other reason (an XML tag for example) you will need to echo these lines >to prevent errors. For example:

<?php echo '<?xml version="1.0" encoding="IUTF-8"?>'; ?>

Renier
  • 1,523
  • 4
  • 32
  • 60
  • This is probably only valid if short tags are allowed. – Shomz Dec 11 '13 at 07:21
  • As suggested, you can use the full php tag, because as in the example, he uses full php tags to echo out the xml. so I dont think this is only valid if if short tags are allowed. – Renier Dec 11 '13 at 07:26