Jump to content


Photo

Script Error


  • Please log in to reply
7 replies to this topic

#1 wiseguy

wiseguy
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 22 September 2006 - 02:04 PM

I have a topsites script that is displaying an error after moving to a new web host. The error reads:
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

Any ideas on what would cause this?


#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 22 September 2006 - 02:06 PM

Could you show us the source code? We can't help you if we do not have it.

#3 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 22 September 2006 - 02:18 PM

You either specified the wrong length in the second parameter of the fread or the file is empty.

Ronald  8)
RTFM is an almost extinct art form, it should be subsidized.

#4 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 22 September 2006 - 02:25 PM

just as ronald said, wrong second parameter.  my guess is that you're leaving it out:

string fread ( resource handle, int length )


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

$contents = fread($handle, filesize('file name here'));

#5 wiseguy

wiseguy
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 22 September 2006 - 02:57 PM

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:
function get_file($url,$read='r') {
		$a = fread(fopen($url, $read),filesize ($url));
		return $a;


#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 22 September 2006 - 02:58 PM

You could just change it to:
function get_file($url,$read='r') {
		$a = fread(fopen($url, $read));
		return $a;

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

#7 wiseguy

wiseguy
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 22 September 2006 - 03:13 PM

You could just change it to:

function get_file($url,$read='r') {
		$a = fread(fopen($url, $read));
		return $a;

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


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


#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 22 September 2006 - 03:18 PM

Hmm. Apparently fread do require the length paramenter. Didn't though it did...

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users