2 Replies - 2293 Views - Last Post: 03 December 2008 - 04:32 PM Rate Topic: -----

#1 tiff88  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 09-July 08

fread() error message

Post icon  Posted 03 December 2008 - 03:56 PM

Hi all,

I get the following error message when I try to run the code below

Warning: fread() [function.fread]: Length parameter must be greater than 0 in entrance.php on line 27



I have already checked the permissions on the file and everything is fine that way. I have no idea why this isnt working. Any advice or help is appreciated.
Thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns = "http://www.w3.org/1999/xhtml">
   <head>
 
	  <?php
		 extract( $_POST );

		 if ( !$password ) {
			die("Please make sure that you have entered a password");
		 }

		
			 $file = fopen(  "minpass.txt", "r" ) or die("Could not open file");
 		 
		

			   // read line from file
			   $line = fgets( $file,15);
		
	if($password == $line){
	$file = fopen("data.txt", "r" ) or die ("Could not open file");
			
			  $contents = fread ($file,filesize ("data.txt"));
			
				

			fclose($file);
			





		}else{
			die("See u later !");
			}
		 ?>
   </body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: fread() error message

#2 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 543
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: fread() error message

Posted 03 December 2008 - 04:27 PM

I tested it locally and it works fine. The only other modification I can think of for you would be to perhaps try this:

	if($password == $line){
	$filename = "data.txt";
	$file = fopen($filename, "r" ) or die ("Could not open file");
			
			  $contents = fread ($file,filesize($filename));
			
				

			fclose($file);


Instead of this:

	if($password == $line){
	$file = fopen("data.txt", "r" ) or die ("Could not open file");
			
			  $contents = fread ($file,filesize ("data.txt"));
			
				

			fclose($file);


Barring that, perhaps insert phpinfo(); at the start of your script and see if allow_url_fopen is On or Off. I doubt that'd have any bearing on it, but your code is syntactically correct.
Was This Post Helpful? 0
  • +
  • -

#3 tiff88  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 57
  • Joined: 09-July 08

Re: fread() error message

Posted 03 December 2008 - 04:32 PM

thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1