Jump to content

Php Linux Vs Windows Differences


sigmadog

Recommended Posts

I've built a script for a client's web site that works great when I test it on my Linux/Apache server here at TotalChoice, 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. 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>");

}

 

}

?>

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

 

Here is a link to the test page on my site that works fine:

 

test form

 

Any help is greatly appreciated. I've been beating my head on my desk over this for about 3 hours now and can't figure it out.

Link to comment
Share on other sites

Okay. I've been fiddling with it. I added the following to the script:

 

ini_set ("display_errors", "1");

error_reporting(E_ALL);

 

and the resulting errors pointed to a permissions problem with the 1nc_alerts.php file. It appears that the server is not allowing me to change the permissions on that file. So I'll need to contact the host and have them do it.

 

Yet another reason why TotalChoice Hosting is tops. With cPanel, I never would have this problem on any of my sites that are hosted here.

 

Now if I can just convince the client to move their site to TotalChoice...

Link to comment
Share on other sites

and the resulting errors pointed to a permissions problem with the 1nc_alerts.php file. It appears that the server is not allowing me to change the permissions on that file. So I'll need to contact the host and have them do it.

 

Yet another reason why TotalChoice Hosting is tops. With cPanel, I never would have this problem on any of my sites that are hosted here.

Trust me it happens on TC as well. I have had to submit a ticket before now due to files/folders I could not delete.

 

Sometimes if you create a file using PHP you cannot touch it using FTP (not saying this happens on TC these days).

Link to comment
Share on other sites

The reason you wouldn't be able to change permissions is because when you create file from PHP it creates them with 'owner' being 99 (which I believe is 'apache').

You will not be able to delete or chmod a file created by PHP from within FTP.

 

I had this issue with one of my sites when I was dynamically creating directories from within PHP. The solution for me was to use PHP's FTP commands to use FTP to create the directories (the owner would then not be apache) and I could then manage them via FTP. I also use this method when I want to allow PHP to create files in directories which do not have 777 permissions. I FTP in (via PHP) chmod the directory to 777, create the file, chmod the directory back to 755 or whatever it was, and close the FTP connection. I feel this is a much safer way than leaving directories open with 777 permissions.

Link to comment
Share on other sites

The reason you wouldn't be able to change permissions is because when you create file from PHP it creates them with 'owner' being 99 (which I believe is 'apache').

You will not be able to delete or chmod a file created by PHP from within FTP.

 

I had this issue with one of my sites when I was dynamically creating directories from within PHP. The solution for me was to use PHP's FTP commands to use FTP to create the directories (the owner would then not be apache) and I could then manage them via FTP. I also use this method when I want to allow PHP to create files in directories which do not have 777 permissions. I FTP in (via PHP) chmod the directory to 777, create the file, chmod the directory back to 755 or whatever it was, and close the FTP connection. I feel this is a much safer way than leaving directories open with 777 permissions.

 

Thanks, OJB. I'll see if I can make it work that way, since I haven't been able to contact the server host yet.

Link to comment
Share on other sites

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.   Paste as plain text instead

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