rockinaway Posted September 9, 2007 Share Posted September 9, 2007 if ($fp = @fopen('folder/file.php', "w")) { // Write the data to the file fwrite($fp, $data); // Close the file fclose($fp); } else echo $_POST['content']; My script won't open the file and write the content.. the $data is declared.. is there something I am missing? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted September 9, 2007 Share Posted September 9, 2007 Well, it would be nice if you told us what does happen when you try this code. However, im going to assume that nothing happens - ie, you get no error messages, but there is no writing to the file. If you are having problems with a script, it's generally a good idea to remove the error suppresion(@). Try changing this line: if ($fp = @fopen('folder/file.php', "w")) To: if ($fp = fopen('folder/file.php', "w")) Post the error message if you get one. Quote Link to comment Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 Warning: fopen(folder/file.php) [function.fopen]: failed to open stream : Permission denied in test.php That is what I get (modified file names ) The folders have got the correct permissions though.. Quote Link to comment Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 The files have got permissions of 644, and the folders 777 Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2007 Share Posted September 9, 2007 file permissions of 644 will probably not allow a write by the server. Also, you might want to use the complete path to the file. fopen("/home/somewhere/folder/file.php","w"); Quote Link to comment Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 Ok I changed the permissions.. but now when my file is written, hunderds of \s appear before my quotes and then there are extra linebreaks ater every line.. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2007 Share Posted September 9, 2007 don't know what that is, haven't seen $data. Quote Link to comment Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 I have added stripslashes() but that doesn't seem to have any effect Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 9, 2007 Share Posted September 9, 2007 what is in $data? Can you show us? Quote Link to comment Share on other sites More sharing options...
rockinaway Posted September 9, 2007 Author Share Posted September 9, 2007 Data it just the contents from a previous PHP file, that is sent through $_POSTS, via a textarea in a form. So it contains lots of the $,'," stuff... Quote Link to comment 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.