Hi,

im trying to run the following code:

<?
  ob_start();
   include('niver.php');
   $niver = ob_get_contents();
  ob_end_clean();
  ob_start();
   include('ranking.php');
   $ranking = ob_get_contents();
  ob_end_clean();
  ob_start();
   include('menu.php');
   $menu = ob_get_contents();
  ob_end_clean();
  ob_start();
   include('novidades.php');
   $novidades = ob_get_contents();
  ob_end_clean();
  ob_start();
   include('server_status.php');
   $server_status = ob_get_contents();
  ob_end_clean();

  $principal = implode('', file('principal.htm'));
  $principal = str_replace('[menu]',$menu,$principal);
  $principal = str_replace('[niver]',$niver,$principal);
  $principal = str_replace('[novidades]',$novidades,$principal);
  $principal = str_replace('[ranking]',$ranking,$principal);
  $principal = str_replace('[server_status]',$server_status,$principal);


  echo $principal;


?>

But it seems that was a problem with the ranking.php (blank screen) because i removed the file ranking.php from server and the code worked well with all other php files.
So i checked the ranking.php for errors writing a test.php with:

<? 
include('ranking.php')
?>

and the result was just right.
So in the end it seems that ob_get_contents is giving an error only with ranking.php.
Any ideas?

    why are you doing all that start and clean with the output buffering on every include?

      i think its not the right technique you're using now.

      But here is an example:

      <?php
      
      function ob_include_array( $fn , $template )
      {
          foreach( $fn AS $f ) {
              if ( is_file( "$f.php" ) ) {
                  ob_start();
                  $array[$f] = "[$f]";
                  include( "$f.php" );
                  $data[$f] = ob_get_contents();
                  ob_flush();
              }
          }
          $contents = file_get_contents( $template );
          return str_replace( $array , $data , $contents );
      }
      
      $fn = array( "menu", "niver", "ranking", "novidades", "server_status" );
      echo ob_include_array( $fn , "principal.htm" );
      
      ?>

        djjjozsi, thank you for your attempt but your code just echoed the ranking.php output.

        I must say i discovered that the problem is something between the two scripts (server_status and ranking) and not with ranking. They just produce the blank screen if they are loaded together. I commented each of them while lefting the other one uncommented and things went just fine.
        I studied each code and the only function i use on both is one i declare in each file (is the same func but i declare in each one anyway) and file_get_contents.
        This last one is acessing different external sites to get the content.
        Any ideas?

          Well after some time, came to my mind this:

          <?
          
            $principal = implode('', file('principal.htm'));
            $principal = str_replace('[menu]',$menu,$principal);
            $principal = str_replace('[niver]',$niver,$principal);
            $principal = str_replace('[novidades]',$novidades,$principal);
            $principal = str_replace('[ranking]',file_get_contents('http://www.headhuntersguild.net/dev/ranking.php'),$principal);
            $principal = str_replace('[server_status]',file_get_contents('http://www.headhuntersguild.net/dev/server_status.php'),$principal);
          
          
            echo $principal;
          
          
          ?>

          and it worked well.
          So i guess its solved.

            Write a Reply...