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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.