PHP works from URL but not within HTML File

The website I design is all html, htm and shtml files. Recently I was asked to create a process whereby the website will utilize multiple footer files. These were initially called in via an SSI include statement but the number has grown and now want to manage it using PHP.

I created a php file that has a switch/case statement and selects the footer data based on an ID passed to it from the html file. Here’s the issue, when I run it from the URL line everything works perfectly. However, when I try to incorporate <? include("includes/thescript.php?id=5"); ?> into the HTML pages, it stops working.

I know it has something to do with the inability for the PHP to be read by the html, etc. So, I updated the .htaccess file…multiple times and a few different options. None of them work.

I also tried adding the PHP via an iframe and this did work but I lost all of my formatting, css, etc. I don’t know much about iframes so I backed out of that.

  1. Works from URL
  2. Works inside iframe
  3. Does not work from HTML

Anyone have any ideas what I could try next? I’ve spent many many hours trying different htaccess configurations. Keep in mind that I still use SSI (the html and htm act as shtml files) so I don’t want to lose that functionality.

I appreciate any input whatsoever! Thanks in advance!!

p.s. Just for clarification, the php include statement I am actually using is:

<?php include("includes/phpscript.php?id=5"); ?>

Also, I cannot convert my html/htm files to php - the person who I design this for says it will affect his google rating, yada yada. Anyways, I also recreated one of the files from html to php and it worked perfectly for everything except the php I was trying to include (above). Also renamed it to .inc and same results.

Trying anything and everything at this point. Maybe its just something stupid that I haven’t seen yet.

Sorry to keep bumping my own message but I’ve updated some stuff and wanted to share this before people jump on me for why this or that doesn’t work :slight_smile:

I figured out why the variable was working in the direct PHP file and would have never worked in the html file. I updated the code as follows:
[php]<?php $v = "100"; echo $v; include("includes/phpscript.php"); ?>[/php]
this now passes the variable, in thi case 100, to the php script where it is extracted and utilized.

I also renamed the .html file to .php and it does work so there is obviously something wrong with the server configuration but I just cannot figure it out. I’ve tried many different .htaccess configurations - does anyone know if there would be something else preventing this from running via html? Maybe something they’ve experienced and would help me out? Thanks again in advance. Hope to hear from someone.

Sponsor our Newsletter | Privacy Policy | Terms of Service