miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
The Other miniBB Support Forums / The Other /   

PHP Warning - Length parameter must be greater than 0

Author harootun
#1 | Posted: 6 Feb 2011 22:45 
I've checked my PHP log, and I see the following warning repeated:

PHP Warning: fread() [<a href='function.fread'>function.fread</a>]: Length parameter must be greater than 0 in /Users/JoeBlow/website/minibb/bb_functions.php on line 22

line 22 of bb_functions.php is: $tpl=fread($fd, filesize($fload));

Is this anything to be worried about? Anything I can make go away?

Sorry for my ignorance!

Author tom322
#2 | Posted: 6 Feb 2011 23:37 
Maybe you removed/don't use one of the default templates that givese the warning. I would try to enter a space in this template and save it again.

Author Paul
Lead Developer
#3 | Posted: 7 Feb 2011 04:34 | Edited by: Paul 
Yes, it means you have modified some template and completely deleted its content. Such error may appear when fread() function of PHP tries to read an empty file. Put a space or newline in this file.

How to determine the name of the template - in bb_functions.php, right after the function's statement put the following:

function makeUp($name,$addDir='') {
echo $name;

then run the script and watch the error report - PHP will drop the notice right after the template's name.

Author harootun
#4 | Posted: 7 Feb 2011 13:01 
Yes, that was it! Found the problem template and put a space in there! Thanks so much!

Author Ricardo
#5 | Posted: 23 Feb 2011 09:13 | Edited by: Ricardo 
Thanks too! I had the same error and now its fixed.

But i think i found a error in the forum search. First time i searched for fread(); and instead of the result page i get the following error:


You don't have permission to access /forums/index.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/ Server at ... Port 80

Author Paul
Lead Developer
#6 | Posted: 23 Feb 2011 09:52 | Edited by: Paul 
If you are about Search on our forums - yes, it will give that error if the search phrase contains parentheses. For some reason parentheses are perceived by the server where we host miniBB like they would a filename or something. We just don't know why it happens currently. I think investigating it on the hoster's side would take years :) Anyway I'll try to know these guys about that, thanks.

So by now if something like this happens, try to improve your search, search for simply 'fread' for example.

It's only related to our server, it works by default on all proper configurations.

P.S. Hmm no I was wrong, it only happens if you type fread() / fwrite()! No other combination with parentheses. Strange! I'll disturb the hoster right now :)

Author Ricardo
#7 | Posted: 23 Feb 2011 09:53 
Ok, good to know. Thanks for that information!

Author tom322
#8 | Posted: 23 Feb 2011 15:05 
I'll disturb the hoster right now :)

I also think it's hoster's custom security settings; from what I tested it works on some hosts correctly while on another not. I tend to think not to disturb hosters too much as there may be a risk they screw something even more ; ).

Author Paul
Lead Developer
#9 | Posted: 24 Feb 2011 03:43 
It is hoster's job, to solve such errors. So it's always nice to disturb them, because the money is paid for that.

This is what they replied:

The forbidden message you are seeing is due to the search script that is being used hitting our Mod Security rule set. The mod security rule is in place to protect against common PHP injection attacks. In some cases it returns false positives due to the manner in which the script operates. Unfortunately, we can disclose the exact rule for security reasons.

They also suggested to whitelist our domain for this rule so that when searching for those variables, it will be allowed through the rule set.

I disagreed with that. There is nothing critical comes regarding this point comparing to security.

So like I replied above, do not use major PHP functions in search. Skipping parentheses and other system symbols, leaving the phrase characters clean, will help.

Author ramya
#10 | Posted: 4 Jun 2012 07:49 
try adding at symbol before fread

Author Paul
Lead Developer
#11 | Posted: 4 Jun 2012 17:56 
try adding at symbol before fread

This will eliminate the appearing of the problem, but not the problem itself.
Obviously, most often this error comes up because of some empty template or file.

Author lily3kms
#12 | Posted: 29 Jul 2013 01:43 
can someone help me.. i have this problem

Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home1/laile/public_html/bbs/lib.php on line 1010

how to solve it??


Author Paul
Lead Developer
#13 | Posted: 29 Jul 2013 13:02 
Go to the line 1010 of lib.php, this script tries to fread some file, which obviously has 0 bytes in length.
How to fix it? Not sure. This script is not related to miniBB.

The Other miniBB Support Forums / The Other / PHP Warning - Length parameter must be greater than 0 Top

Your Reply Click this icon to move up to the quoted message

 Short link for this topic:

Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.

Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB