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 8 of 8

Thread: Changing HTML

  1. #1
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts

    Changing HTML

    Hi there, i have problem in which im designing a system that will include a HTML file and then replace some of HTML with PHP and then output. But Im having a problem where the PHP i replaced does not execute instead it shows up in the HTML itself.

    So here is the code that does the work :

    PHP Code:
        function compile($file){
            
    // uses smarty method

            
    $outfile=file_get_contents($file);
            
            
    // remove all include tags
            
    preg_match('<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->'$outfile$this->match);
            
    $code=preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+) -->#'$this->wrap_php($this->exchange_include('$1')), $outfile);
                    
            return 
    $code;

        } 
    But it only outputs the following HTML :
    Code:
    <body onload="preloadImages();">
    <div id="wrapper">
    <?php include('./includes/header.php'); ?>
    <div id="col-one">
    <?php include('./includes/col-one.php'); ?>
    
    </div>
    <div id="col-two">
    <?php include('adcol'); ?>
    <?php include('recentcol'); ?>
    
    <div class="mainboxed">
    <h2 class="title" onclick="showHideDiv('news')"><img src="images/arrow_down.png" border="0" class="collapsearrow" /><? echo $rows['blog_title']; ?></h2>
    <div class="content" id="news">
    <p><img src="./images/css.jpg" class="newslogo">Posted by <a href="view_member.php?id=<? echo $uid; ?>" class="admin"><? echo $rows['blog_author']; ?></a> on <? echo $time; ?></p><br>
    <p><? echo BBCode($rows['blog_detail']); ?>
    </p><div style="clear:both;"></div>
    <br><p class="comments"><a href="newspost.html">Replies (2)</a> <a href="#" class="buttonfake">Reply</a></p>
    
    </div>
    </div>
    
    </div>
    
    
    <div id="col-three">
    <? include './includes/col-three.php'; ?>
    
    </div>
    
    
    </div>
    <? include './includes/footer.htm'; ?>
    </body>
    What do i need to do to make these php snippets to execute?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Your server is set-up to run PHP scripts if the file extension is .php (not .html).

    You can command the server to process your .html (or .htm) files as PHP by
    using the .htaccess file ... if you know what that file is.

    Or, simply change the extension of your "index.html" (or whatever) to "index.php".

    Look on Google for: http://www.google.com/search?hl=en&r...&aql=&aqi=&oq=

  • #3
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    No the file i run is still a php extension its just i pretty much extract the HTML from a HTML file, change the contents then output it. But it doesnt work by when theres php in the changed HTML code.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    It must be missing the <html>, doc-type, and content-type?
    Not enough information to determine what it is.

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    added, but still the same result happens.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    I see the word "smarty" ... is this a "smarty" application?
    Maybe they take out all <?php coding.

  • #7
    Regular Coder
    Join Date
    Mar 2009
    Location
    United Kingdom
    Posts
    161
    Thanks
    6
    Thanked 28 Times in 28 Posts
    Well, im using the smarty method by which, they replace certain HTML blocks with php and it executes like that, but its not working so well with my script.

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    I guess that I don't know enough about Smarty to give you a good answer.
    maybe someone else will "pipe-in" with something.


  •  

    Posting Permissions

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