Jump to content

Archived

This topic is now archived and is closed to further replies.

wiseguy

Script Error

Recommended Posts

I have a topsites script that is displaying an error after moving to a new web host. The error reads:
[code]Warning: fread() [function.fread]: Length parameter must be greater than 0. in /home/karaoket/public_html/top-karaoke-sites/admin/lib/class.functions.php on line 723[/code]

Any ideas on what would cause this?

Share this post


Link to post
Share on other sites
You either specified the wrong length in the second parameter of the fread or the file is empty.

Ronald  8)

Share this post


Link to post
Share on other sites
just as ronald said, wrong second parameter.  my guess is that you're leaving it out:

[quote]string fread ( resource handle, int length )[/quote]

from the php manual - note that the second parameter is NOT optional.  this is usually what an fread() should look like:

$contents = fread($handle, [b]filesize('file name here')[/b]);

Share this post


Link to post
Share on other sites
The script was working before I moved it to a new host. I simply copied the script files and imported the database. The function at line 723 is:
[code]function get_file($url,$read='r') {
$a = fread(fopen($url, $read),filesize ($url));
return $a;[/code]

Share this post


Link to post
Share on other sites
You could just change it to: [code]function get_file($url,$read='r') {
$a = fread(fopen($url, $read));
return $a;[/code]

The filesize thing just gets the total filesize, but fread will by default read everything, so you do not need that.

Share this post


Link to post
Share on other sites
[quote author=Daniel0 link=topic=109070.msg439439#msg439439 date=1158937117]
You could just change it to: [code]function get_file($url,$read='r') {
$a = fread(fopen($url, $read));
return $a;[/code]

The filesize thing just gets the total filesize, but fread will by default read everything, so you do not need that.
[/quote]

That just produced another error
[code]Warning: Wrong parameter count for fread() in /home/karaoket/public_html/top-karaoke-sites/admin/lib/class.functions.php on line 723[/code]

Share this post


Link to post
Share on other sites
Hmm. Apparently fread [i]do[/i] require the length paramenter. Didn't though it did...

Well, this should work: [code]function get_file($url) {
return file_get_contents($url);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.