Jump to content

writng to a text file under linux


mscava

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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.