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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.