Jump to content

Archived

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

mscava

writng to a text file under linux

Recommended Posts

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:

[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;
?>[/code]

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

Share this post


Link to post
Share on other sites
You can start by removing all your snails (@) and see what errors you get

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.