Jump to content


Photo

writng to a text file under linux


  • Please log in to reply
2 replies to this topic

#1 mscava

mscava
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 October 2006 - 02:55 PM

first of all... i am newbie...

well i'm trying to code a simple guestbook. i have ubuntu 6.06. the problem is that i just can't write into a file. i guess it has something to do with permissions. but my file book.txt has em -rw -rw -rw.

here is my code:

<?php
	$path = "book.txt";
	if ($action=='save'):		
		@$file = fopen($path, "r");
		@$content = fread($file, filesize($path));
		@FClose($file);
		if (($message=="") or ($nick=="")):
			echo "<p>Nie su vyplnene pozadovane udaje!</p>";
		else:
			$file = fopen($path, "w");
			$str = "<div><h4>".$nick.", ".Date("d-m-Y, H:i:s")."</h4><p>".$message."</p></div>";
			fputs($file, "$str");
			fputs ($file, "$content");
			FClose($file);
			
			@$file = fopen($path, "r");
			@fpassThru($file);
		endif;
	else: 
		@$file = fopen($path, "r");
		@fpassThru($file);
	endif;
?>

anyone has any ideas what to do... or is it the code's fault?

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 02 October 2006 - 03:03 PM

You can start by removing all your snails (@) and see what errors you get

#3 mscava

mscava
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 02 October 2006 - 03:07 PM

i got no errors




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users