Assistance with Saving to File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andrewmcgibbon
Forum Newbie
Posts: 2
Joined: Thu Aug 15, 2002 3:36 pm
Location: New Jersey

Assistance with Saving to File

Post by andrewmcgibbon »

I am using the following PHP code to process fields from a form. I am presently getting the following error.

Warning: fopen("me.txt", "a+") - Permission denied in /home/www/insidebroadway.org/friend_form_handle.php on line 20

I have confirmed with my ISP that the permissions are set up properly (which would make sense since I can ftp html files to this directory). What I'm ULTIMATELY trying to do here is use datestamp() to create a unique file name (as you can probably see from the commented out lines.)

Thanks so much for your help. --Andy

Here's the PHP code:

<?
//PHP Script to save variables into file.

function WriteToFile ($firstName, $friendsEmail, $message){

//Creating a Date String to create unique file names.
$TheDate = time();
$DateString = $TheDate . ".txt";
$TheFile = "test.txt";

$Open = fopen("me.txt", "a");
if ($Open) {
fwrite ($Open, "$firstName+\r$message");
fclose($Open);
$Worked = TRUE;
} else {
$Worked = FALSE;
}
return $Worked;
}
//Call the function.
WriteToFile($firstName, $fiendsEmail, $message);

?>
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

try chmoding the file thru your ftp.
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

Hob is right... The permissions are definitely not set right! Try making them 666 or read/write for all.
andrewmcgibbon
Forum Newbie
Posts: 2
Joined: Thu Aug 15, 2002 3:36 pm
Location: New Jersey

Post by andrewmcgibbon »

Thanks everyone for your help on this. It was a combination of incorrectly set permissions and the fact that I was not picking up the variables correctly. Those variables were part of an array and I didn't provide the name of the array.

Thanks to all who who replied.

Andy
Post Reply