0

OK this code here should include "lol_url" file:

<?php
  $file = 'lol_count.txt';
    $data = @file($file);
    $data = $data[0];
  if($handle = @fopen($file, 'w')){
    $data = intval($data); $data++;
  fwrite($handle, $data);
  fclose($handle);
}
  header('Location: '.include ('lol_url').'');
?>

the "lol_url" file contains an url address, such as:
http//www.example.com

How can I make this work because it gives me this error:

Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\max\xxx\88x31\lol_url:1) in E:\xampp\htdocs\max\xxx\88x31\lol_count.php on line 10

,and I would like to keep the address in "lol_url" as it is! Thanks

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by EvolutionFallen
0

You can't send header information once you've already started outputting information. fwrite($handle, $data) is sending output. Either that or there's somewhere earlier in the file where output is being sent to the page. You should use PHP's output buffering to fix this:

<?php

ob_start(); // begin output buffering

  $file = 'lol_count.txt';
    $data = @file($file);
    $data = $data[0];
  if($handle = @fopen($file, 'w')){
    $data = intval($data); $data++;
  fwrite($handle, $data);
  fclose($handle);
}
  header('Location: '.include ('lol_url').'');

ob_end_flush(); // flush the buffer
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.