Page 1 of 1

Newbie problem writing to a file...

Posted: Thu Mar 31, 2011 8:38 pm
by BuckeyeTheDog
Newbie here... Thanks for your help.

I am using the "How to do everything in PHP & MySQL" book. I am learning how to write to a file. I am having problems noted below...

For this php code...

Code: Select all

<?php>
	
	$file = 'WriteTest.txt';

	$fh = fopen($file, 'w') or die('What the hell, this did not work at all.');
	
	fwrite($fh, 'We will see if this really works.') or die('Could not write to file.');

	fclose($fh);
	
?>
I am getting this returned...


Warning: fopen(WriteTest.txt) [function.fopen]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/ReadWriteFileExample.php on line 5
What the hell, this did not work at all.

I have ensured that the htdocs folder has read write access. I'm not sure what I am doing wrong.

Any ideas? Thanks in advance, BtD

Re: Newbie problem writing to a file...

Posted: Fri Apr 01, 2011 10:00 am
by social_experiment
Is the file WriteTest.text in the same directory as ReadWriteFileExample.php?