Jump to content

[SOLVED] Can't write to a file on NT server


sigmadog

Recommended Posts

I've built a script for a client's web site that works great when I test it on the Linux/Apache server on my web site, but it won't work on their site, which, according to the phpinfo() script, is Windows NT ST3-WEBHOST 5.2 build 3790 using ISAPI server API.

 

The script takes input from a form and writes it to a text file for use as an include in other pages.

 

Having a little experience building php on Apache, and absolutely none on NT, I'm sure I goofed up somewhere. Error detection has indicated some sort of permissions problem having to do with the difference between Apache files and NT files, but I can't figure it out. Here is my script below. Is there anything obvious that needs to be changed for the WINDOWS NT server?

 

==========================================

 

<?php

if (isset($_POST[submit])) {

$alertFile = "inc/inc_alerts.php";

$Open = fopen ($alertFile, "w");

$redStatus = $_POST['redRouteStatus'];

$blueStatus = $_POST['blueRouteStatus'];

$greenStatus = $_POST['greenRouteStatus'];

$ruralStatus = $_POST['ruralRouteStatus'];

$linkStatus = $_POST['linkRouteStatus'];

 

if ($Open) {

fwrite ($Open, "<?php\n\t\$routeRed = \"$redStatus\";\n\t\$routeBlue = \"$blueStatus\";\n\t\$routeGreen = \"$greenStatus\";\n\t\$routeRural = \"$ruralStatus\";\n\t\$routeLink = \"$linkStatus\";\n?>");

fclose ($Open);

$Worked = TRUE;

echo ("<p>The form was successfully processed.</p>\r\n<p><a href=\"alerts_admin.php\" target=\"_self\">Click here</a> to refresh the page with the new information.</p>");

} else {

$Worked = FALSE;

echo ("<p>System error. Please try again. Contact webmaster if problems continue.</p>");

}

 

}

?>

 

=====================================================

 

Thanks for any help.

Link to comment
Share on other sites

It would really help if you posted the actual error message.

 

If the error actually is due to a permissions problem, the folder where the file is located probably does not have the necessary permissions for the USER that the web server/php is running as.

Link to comment
Share on other sites

"Error detection has indicated some sort of permissions problem having to do with the difference between Apache files and NT files"

oh, didn't read that...

just set the properties on your NT box to READ WRITE EXECUTE to everyone

not like it'd make much difference to security (lol)

Link to comment
Share on other sites

Thanks for the quick responses. As a follow up, here is the error message:

 

Warning: fopen(inc/inc_alerts.php) [function.fopen]: failed to open stream: Permission denied in D:\SERVERNAME\www\new\alerts_admin.php on line 54

 

Line 54 is:

 

$Open = fopen ($alertFile, "w");

 

It appears that the server settings will not allow me to modify file permissions. I tried to change the permissions of "inc_alerts.php" to 777 (via ftp client) but it didn't change. They remain at 666 (though I thought that would work).

 

So it looks like I need to contact the server administrator and have them change the permissions for me. Is that the solution, or am I missing something?

Link to comment
Share on other sites

Under Windows, you have to change the permissions on the server. You might have the ability to do this through your hosting control panel or if you create the folder through your hosting control panel rather than through your ftp client/upload.

 

Yeah, that's what I figured. Unfortunately, I'm doing this project for a client who doesn't know the first thing about this stuff (makes me feel like a friggin' genius), and doesn't have any login info for the control panel. I'm waiting to hear from someone else in the organization who might be able to track this stuff down.

 

Thanks for your help.

 

I consider this problem solved for all practical purposes.

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.