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
KG
Forum Newbie
Posts: 8 Joined: Tue Sep 26, 2006 4:11 pm
Location: Lexington, KY / Huntsville, AL
Post
by KG » Mon Oct 23, 2006 2:49 pm
I'm trying to learn how to create files, so i wrote a simple php script that shoulld, theoretically create a new .txt file.
My Code is:
Code: Select all
<?php
$filename = "testFile.txt";
echo "string created. ";
$filehandle = fopen($filename,'w') or die("can't open file");
echo "file opened. ";
fclose($filehandle);
echo "file closed. ";
?>
My Output is:
Can anybody see a problem or how to fix this?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Mon Oct 23, 2006 3:02 pm
Have you checked our directory permissions?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Oct 23, 2006 3:07 pm
And make php's error reporting more verbose, maybe it wants to tell you something
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
$filename = "testFile.txt";
echo "string created. ";
$filehandle = fopen($filename,'w') or die("can't open file");
echo "file opened. ";
fclose($filehandle);
echo "file closed. ";
?>
KG
Forum Newbie
Posts: 8 Joined: Tue Sep 26, 2006 4:11 pm
Location: Lexington, KY / Huntsville, AL
Post
by KG » Mon Oct 23, 2006 3:40 pm
It was indeed the permissions. Good call hawleyjr, and thanks for the advice volka. Kudos to you both.