dsaba Posted May 19, 2007 Share Posted May 19, 2007 i'm using this line of code: <?php $lang = "he"; $text = "whatever\n"; $handle = fopen("/home/www/website.host.com/folder/".$lang."translations.php", "w") or die('Cannot open file'); fwrite($handle, $text) or die('Cannot write to file'); fclose($handle) or die('Cannot close file'); ?> it does not error, so it doesn't say "cannot open file" the file does not exist on my server, i am attempting to create it with "w" which supposedly should create the file if it doesn't already exist well it DOESN'T and it still doesn't error? How do I make it create a file if it doesn't exist?? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/52101-fopen-function-does-not-create-a-new-file/ Share on other sites More sharing options...
MadTechie Posted May 19, 2007 Share Posted May 19, 2007 you checked file/folder permissions ? the W Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. Quote Link to comment https://forums.phpfreaks.com/topic/52101-fopen-function-does-not-create-a-new-file/#findComment-256865 Share on other sites More sharing options...
neel_basu Posted May 19, 2007 Share Posted May 19, 2007 try using wb+ mode Quote Link to comment https://forums.phpfreaks.com/topic/52101-fopen-function-does-not-create-a-new-file/#findComment-257124 Share on other sites More sharing options...
JakeTheSnake3.0 Posted May 19, 2007 Share Posted May 19, 2007 Are you even referencing the correct folders? Try uploading a test document, and try doing an fopen using the same folder reference that you have there...except just take out the variable and replace it with the language folder in which you placed your test file. Quote Link to comment https://forums.phpfreaks.com/topic/52101-fopen-function-does-not-create-a-new-file/#findComment-257126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.