View Full Version : Execute php script within and html file

01-23-2012, 05:59 AM

I've ran myself into a little brain fart here!

I have this iddy bitty script

$data_file = $_SERVER['DOCUMENT_ROOT'] . "/data/field_status.txt";
$fstat = file($data_file);
$count = count($fstat);

echo "<div id='field_status_containter'>\n";

for ($i = 0; $i <= $count-1; $i++) {
$field_status = explode('||',trim($fstat[$i]));
$field = $field_status[0];
$stat = $field_status[1];
if ($field_status[1] == "OPEN") {
$span_status = "field_status_open";
{ $span_status = "field_status_closed";}
$dt = $field_status[2];
echo " <span id='field_name'>$field</span><span id='$span_status'>$stat</span><span id='field_date'>$dt</span>\n";

echo "</div>\n";

and I tried to call it the html file like such

<div id="field_status">
<div id="field_status_overlay">
<?php include 'scripts/field_status/fieldstatus.php'; ?>

When I view the source for that I see

<div id="field_status">
<div id="field_status_overlay">
<?php include 'scripts/field_status/fieldstatus.php'; ?>


The html page itself is in the document root. I have no problem with running php script and have php in other documents that execute from within html no problem. This guy wants to be a pain!

Any help is greatly appreciated!

01-23-2012, 06:28 AM
Any file with PHP code, that you want rendered, should have the .php extension. My guess is that your file still has the .html extension.

01-23-2012, 10:25 AM
You could tell apache to treat .html files as php scripts.

01-25-2012, 06:22 AM
Ya know .. this is what I get for doing this when I'm dog tired.

I look up at the address bar in the browser and I saw this -> file:///D:/FTSC2/index.html

DOH! Needless to say when I put in an actual server address everything was OK!

Sorry and thanks so much!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum