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
    New Coder
    Join Date
    Jun 2010
    Posts
    31
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Display multiple highlight_file()

    When I try and use highlight_file() more than once I get http 500 internal server error.
    Is it possible to show 2 files in 1 page, or have I made a mistake in my coding?

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>WebPage</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <h2 class="title"><a href="#">Edit</a></h2>
                    <h3>Data in MySQL </h3>
                    <h1>update.php</h1>
                  <?php 

    function string_syntax_xhtml$string$return false ) {
        
    $highlight highlight_string$stringtrue );
        
    $replace   str_replace(
            array( 
    '<font color="''</font>' ),
            array( 
    '<span style="color: ''</span>' ),
            
    $highlight 
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }

    function 
    file_syntax_xhtml$path$return false ) {
        return 
    string_syntax_xhtmlfile_get_contents$path ), $return );
    }

    string_syntax_xhtmlfile_get_contents'update.php' ) );

    ?>
                  <p></p>
                  <h1>updated.php</h1>
                  <br>
                  <?php 

    function string_syntax_xhtml$string$return false ) {
        
    $highlight highlight_string$stringtrue );
        
    $replace   str_replace(
            array( 
    '<font color="''</font>' ),
            array( 
    '<span style="color: ''</span>' ),
            
    $highlight 
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }

    function 
    file_syntax_xhtml$path$return false ) {
        return 
    string_syntax_xhtmlfile_get_contents$path ), $return );
    }
    string_syntax_xhtmlfile_get_contents'updated.php' ) );

    ?>
    </body>
    </html>
    Last edited by Craigy; 06-23-2010 at 02:31 PM. Reason: Resolved.

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by Craigy View Post
    When I try and use highlight_file() more than once I get http 500 internal server error.
    Is it possible to show 2 files in 1 page, or have I made a mistake in my coding?

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>WebPage</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <h2 class="title"><a href="#">Edit</a></h2>
                    <h3>Data in MySQL </h3>
                    <h1>update.php</h1>
                  <?php 

    function string_syntax_xhtml$string$return false ) {
        
    $highlight highlight_string$stringtrue );
        
    $replace   str_replace(
            array( 
    '<font color="''</font>' ),
            array( 
    '<span style="color: ''</span>' ),
            
    $highlight 
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }

    function 
    file_syntax_xhtml$path$return false ) {
        return 
    string_syntax_xhtmlfile_get_contents$path ), $return );
    }

    string_syntax_xhtmlfile_get_contents'update.php' ) );

    ?>
                  <p></p>
                  <h1>updated.php</h1>
                  <br>
                  <?php 

    function string_syntax_xhtml$string$return false ) {
        
    $highlight highlight_string$stringtrue );
        
    $replace   str_replace(
            array( 
    '<font color="''</font>' ),
            array( 
    '<span style="color: ''</span>' ),
            
    $highlight 
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }

    function 
    file_syntax_xhtml$path$return false ) {
        return 
    string_syntax_xhtmlfile_get_contents$path ), $return );
    }
    string_syntax_xhtmlfile_get_contents'updated.php' ) );

    ?>
    </body>
    </html>
    You are defining the same functions twice. You only need to define them once and then you can call them all you like. Try this instead:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>WebPage</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
    </head>
    <body>
    <h2 class="title"><a href="#">Edit</a></h2>
                    <h3>Data in MySQL </h3>
                    <h1>update.php</h1>
                  <?php
    function string_syntax_xhtml$string$return false ) {
        
    $highlight highlight_string$stringtrue );
        
    $replace   str_replace(
            array( 
    '<font color="''</font>' ),
            array( 
    '<span style="color: ''</span>' ),
            
    $highlight
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }

    function 
    file_syntax_xhtml$path$return false ) {
        return 
    string_syntax_xhtmlfile_get_contents$path ), $return );
    }
    string_syntax_xhtmlfile_get_contents'update.php' ) );
    ?>
                  <p></p>
                  <h1>updated.php</h1>
                  <br>
                  <?php
    string_syntax_xhtml
    file_get_contents'updated.php' ) );
    ?>
    </body>
    </html>
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    31
    Thanks
    10
    Thanked 0 Times in 0 Posts
    That now displays them both perfectly, thank you for the help.

  • #4
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes becuase, highlight_file uses internal output buffering.


  •  

    Posting Permissions

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