Editing an empty post (split off) |
Sat, 29 July 2006 04:53  |
|
m.a@stars |  | Commander | Messages: 2765
Registered: October 2004 Location: Third star to the left | |
|
Hey, I got this while editing an empty post:
Warning: fread(): Length parameter must be greater than 0. in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php:42) in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 3631
[Updated on: Sat, 29 July 2006 04:57]
So many Stars, so few Missiles!
In space no one can hear you scheme!  Report message to a moderator
|
|
|
|
Re: Mid-game gateable missle defence reserve |
Mon, 07 August 2006 01:43   |
|
|
Likely moderator will split this topic off, thanks in advance.
Ron wrote on Sat, 05 August 2006 20:30 |
m.a@stars wrote on Sat, 29 July 2006 04:53 | Hey, I got this while editing an empty post:
Warning: fread(): Length parameter must be greater than 0. in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 42
Warning: Cannot modify header information - headers already sent by (output started at /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php:42) in /var/www/autohost.cathey.us/htdocs/sahforum/theme/Stars/post .php on line 3631
|
Yes, I know... don't know what causes it.
|
A post with no content, only a subject and maybe a poll gets this error if you try to edit it. Line 42 of post.php likely needs a small change by adding an "if size>0" type statement. My php is rusty, but from my php help file:
Quote: | fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when length bytes have been read, EOF (end of file) is reached, or (for network streams) when a packet becomes available, whichever comes first.
<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
?>
|
The above sample to avoid similar problem might be changed to:
Quote: |
<?php
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$readsize = filesize($filename);
if ($readsize>0)
{
$contents = fread($handle, filesize($filename));
}
else
{
$contents = "";
}
fclose($handle);
?>
|
A change similar in style to this to line 42 of post.php may get rid of first warning.
Some other minor tweak to line 42 may get rid of second warning, hard to say exactly without seeing source code, but one option is to fake having something if nothing, eg
Quote: | else { contents="X"; }
| rather than Quote: | else { contents=""; }
|
{Mod edit: fixed quote}
[Updated on: Mon, 07 August 2006 02:48] by Moderator
Report message to a moderator
|
|
|
|