RE: [PHP] What does this error mean?

From: Date: Fri, 29 Jun 2001 18:06:28 +0000
Subject: RE: [PHP] What does this error mean?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55591@lists.php.net to get a copy of this message
it means that the script doesn't have write permission to write the "logs/993700800.log" file... most probably the directory or the file itself are not owned by the webserver user. it also looks like the authour of the script did a real shoddy job of checking for errors, and tried to pass the invalid file descriptor to other functions. (which is what those next two errors are about) one more reason why people *need* to put in error handling code on *all* file or network operations. to fix this the quick-n-dirty way, set correct permissions on the 'logs' directory. to fix this the correct way, first put some error handling in the script, then set file permissions ;) > -----Original Message----- > From: Jimi Malcolm [mailto:jimimalcolm@home.com] > Sent: Thursday, June 28, 2001 3:17 PM > To: php-general@lists.php.net > Subject: [PHP] What does this error mean? > > > I'm trying to from a file in a directory called 'logs'. I've never seen > this error before. What does it mean? > > <<<ERROR>>> > Warning: fopen("logs/993700800.log","w+") - Permission denied in > /home/sites/site20/users/guide/web/counter.php on line 28 > > Warning: Supplied argument is not a valid File-Handle resource in > /home/sites/site20/users/guide/web/counter.php on line 29 > > Warning: Supplied argument is not a valid File-Handle resource in > /home/sites/site20/users/guide/web/counter.php on line 30 > 1 > <<<END>>> > > The last two errors are becuase the first fails to return a file handle. > Here's the actual offending code. It's just a simple counter. > > <<<CODE>>> > <?PHP > $iDate = mktime(0, 0, 0, date("m"), date("d"), date("Y")); > $iCount = 1; > $sFile = "logs/".$iDate.".log"; > > if (file_exists($sFile)) { > $iCount = incCount($sFile); > } else { > createCountLog($sFile); > } > > echo "<B><FONT COLOR=BLUE>$iCount</FONR></B>"; > > function incCount($sFile) { > // Open and read existing count > $hCounter = fopen($sFile, "r"); > $iCount = fgets($hCounter, 1024); > fclose($hCounter); > // Write over it with the new count > $hCounter = fopen($sFile, "w"); > fputs($hCounter, ++$iCount); > fclose($hCounter); > return $iCount; > } > > > function createCountLog($sFile) { > $hCounter = fopen($sFile, "w+"); > fputs($hCounter, 1); > fclose($hCounter); > } > > ?> > <<<END>>> > > Usually I've been able to fix every PHP error I've gotten in the past - > they've been pretty straightforward - but I've been playing around with this > error for a few days now to no avail. > > I'm new to this mailing list and have never used it before so I'm not sure > which one/s to join or post this specific message to. I apologize if this > is the wrong forum for this type of question. Thank you for your time. > > -- > Jimi Malcolm > Web Content Manager > inburst Internet Media > inburst.com > jimi.malcolm@inburst > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#55591) next »