Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    287
    Thanks
    39
    Thanked 0 Times in 0 Posts

    Execute php script within and html file

    Hi!

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

    I have this iddy bitty script
    PHP Code:
    $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";
        }
        else 
            { 
    $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
    Code:
    		<div id="field_status">
    			<div id="field_status_overlay">
    				<?php include 'scripts/field_status/fieldstatus.php'; ?>
    			</div>
    		</div>
    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'; ?>
    </div>

    </div>
    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!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    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.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    You could tell apache to treat .html files as php scripts.
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    287
    Thanks
    39
    Thanked 0 Times in 0 Posts
    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!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs


  •  

    Posting Permissions

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