benphp Posted May 6, 2008 Share Posted May 6, 2008 I can use this code to write to an EXISTING file, but when I try to use it to CREATE a file, it fails - or rather, it doesn't do anything - not even throwing an error. What am I doing wrong? <?php $path = ""; $filename = "myfile.txt"; $fp = fopen($path.$filename, 'w') or die("Sorry charlie"); flock($fp, LOCK_EX); fwrite($fp, "I like almonds"); flock($fp, LOCK_UN); fclose($fp); ?> Thanks! Link to comment https://forums.phpfreaks.com/topic/104409-how-to-create-a-file-then-write-to-it/ Share on other sites More sharing options...
benphp Posted May 6, 2008 Author Share Posted May 6, 2008 Nevermind - it doesn't like flock. Why would flock screw it up? Link to comment https://forums.phpfreaks.com/topic/104409-how-to-create-a-file-then-write-to-it/#findComment-534500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.