Welcome Guest, Not a member yet? Register   Sign In
fwrite() being screwy

One other thing to try in case you have 2 separate processes calling the same code:

$fp = fopen('./logs/somefile.php','ab');
flock($fp, LOCK_EX);
if (($counter = $this->session->userdata('counter')) === false)
    $counter = 0;
$msg = 'TEST'.$counter;    
fwrite($fp, $msg);
$this->session->set_userdata('counter', ($counter + 1));
flock($fp, LOCK_UN);

If you still see "TEST0TEST0", I have no clue. Otherwise you have 2 threads calling the same code segment and the debug backtrace should help you out.

best of luck.

Theme © iAndrew 2016 - Forum software by © MyBB