Jump to content

fopen/fwrite not working properly


Revised

Recommended Posts

Well, to start things out, here is my code being used:

 

<?php

$file = fopen("/mps/projects/project_" . $_POST['projectnumber'] .".php", "w");

echo fwrite($file, " * deleted whats to be written since it's not needed right now, and to save space * ");

fclose($file);

?>

 

The problem I'm having is that the rest of the script up until this point runs fine, but when it's suppose to execute the fopen/fwrite functions it doesn't do so. Also, just to experiment, I went to fopen("/mps/projects/project_" . $_POST... etc. and changed the fopen url to the root directory... looking something like this: fopen("test.php", "w"); echo fwrite($file, " * content * ");... pretty much just taking away all the subdirectories so that the file is created/written to in the base directory, and it works just as i want it to when I take away the extra folders (/mps/projects/). Does anyone see something I've done wrong? I'm still new with PHP but I'm sure it's not a syntax error since all I'm doing is taking away those two directories and it works just fine... I could be wrong.

 

Any and all help/suggestions are very much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/101127-fopenfwrite-not-working-properly/
Share on other sites

Have you checked permissions on the directory you are trying to write to?

 

Seeing as how you can write to the current directory, I'd say that the file functions are broken.  Most likely the Apache user doesn't have permission to write to the directory you are providing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.