Problem Writing To File

From: Randy Jackson (randyjackson_at_nounsolicitedfourcolorexplosion.com)
Date: 10/29/04


Date: Fri, 29 Oct 2004 16:53:58 -0500

Hello all.

Okay, this seems really stupid, but it's driving me up the wall.

I have a simple script I've written to log some information to a text
file. Everything seems to be okay, the code isn't throwing any errors,
but for some reason it isn't writing to file. If anyone has any ideas,
please let me know.

Here's the code I'm using:

//trigger_error("Just Testing to see if this is working",E_USER_NOTICE);
$strTimeStamp=date("F j, Y h:i:s A");
$strLogEntry=$strTimeStamp . ", " . $REQUEST_URI . ", " . $_SERVER
['HTTP_REFERER']. "\r\n";
//echo $strLogEntry;
$logfile='../logs/fce.log';

$logExists=file_exists($logfile);
if($logExists){
echo "File Exists<br>";
}
else{
echo "File Does Not Exist<br>";
}

$writable=is_writable($logfile);
if($writable){
echo "File Can Be Written to<br>";
}
else{
echo "File Cannot Be Written to<br>";
}

$fileHandle=fopen($logfile, "a");

if($fileHandle){
echo "File Opened for writing.<br>";
$written=fwrite($fileHandle, $strLogEntry);
echo "File written to successfully.<br>";
$closed=fclose($fileHandle);
echo "File closed succesfully.<br>";

}
else{
error_log("$logfile does not exist");
}

-- 
Randy Jackson
http://fourcolorexplosion.com


Relevant Pages

  • RE: [SLE] Samba/Wnbind on SuSE 9.0
    ... >winbindd actually finds them okay? ... after you've entered the 'THEIMG' admin password, ... When run both of these commands should echo back ...
    (SuSE)
  • Deconstructing my script
    ... Okay, I have taken apart my script and stripped it down to where it is ... and am now adding back ion small blocks to check each one before ... replace the echo "Got Here" statement)? ...
    (alt.php)
  • Re: Bash Script (WAS:Re: Suse 9.3 on a desktop replacement)
    ... >> I created a batch file called, ... then you need to fix the script above. ... > you really want user feedback in the form of echo commands (and ... Okay, here it goes, this works. ...
    (alt.os.linux.suse)
  • Re: Expect expect beginner question
    ... Okay, another example, I hope, that's ... #and here is the non working code ... send "echo \$?\r" ...
    (comp.lang.tcl)
  • Re: cpu hotplug support broken in 2.6.23-rc3
    ... Trying to do few onlines/offlines reliably hangs my machine (thinkpad ... just echo 0/1> online from commandline... ... echo "okay" ...
    (Linux-Kernel)