Hello,
I have been using this code to update a text file (currenttext.txt) via a web browser. I had it on a Unix server and it was working fine. I tried it on an NT server it stopped working. I have no idea why, can someone help me?

<?php
$updates_filec1 = "currenttext.txt";
$fp = fopen($updates_filec1, "r");
flock($fp,1);
$x = fread($fp, filesize ($updates_filec1));
fclose($fp);
$x = stripslashes ($x);
$update = stripslashes ($update);
if (!empty($update_file)) {
$fp = fopen($updates_filec1, "w");
$fw = fwrite($fp, $update);
fclose($fp);
$x=$update;
echo "Changes were recorded!";
}
echo "
<FORM ACTION=\"refresh.php\" METHOD=POST>
<TEXTAREA NAME=update ROWS=20 COLS=80>$x</TEXTAREA>
<INPUT TYPE=hidden NAME=\"password\" VALUE=\"$pass\"><BR>
<INPUT TYPE=submit NAME=update_file VALUE=Save&nbsp;It></FORM>
";
?>

Thank You

    When you say "stopped working", what exactly do you mean?

    Remember that Windows NT has a different idea about how to end lines of text - it uses \r\n instead of Unix's \n. I'm not sure, but there's a possibility that if you didn't convert the text file when you transferred it then that may cause problems.

      Hello,
      Thanks for responding.

      When I say "it stopped working" here's what I mean:

      Before (on Unix) I was able to edit the textfile and save to the text file.

      Now, when I hit the save button to run the script, it reloads the script, but doesn't actually do anything.

      Perhaps the text file is the issue, How would I go about converting the text file? I'm on a mac.

      Thanks

        Well, Macs are not good for programming lol they are much better for gfx but I do not know how to do this stuff on a mac but after u save it, and it is not readonly you should just have to refresh the page and it should work.

        But I know little about the mac os so yea, have fun figuring it out =)

        -FrosT

          Instead of
          if (!empty($update_file)) {
          try
          using isset()

          Diego

            Thanks for helping Diego,

            I tried replacing:

            if (!empty($update_file)) {

            with

            if (isset() ) {

            but nothing changes,
            is this what you meant?

            thanks

              ravenance, you are extramly ignorent why the hell do u think that macs suck for programming? there better then windows. do u know why? because there running a unix backend (which windoz does not have) and did you know what most web servers run on? *nix so dont go saying macs suck for programming there a hell of a lot better then windows also if they suck so much why does Microsoft use macs to make some of there software? because of its compatibity to compile programs for both pc and mac. this means less work. at least on a mac i can use simple unlink functions instead of system("del file.txt"); (on windoz). i have used various operating systems (linux,unix,osx,os9,windows) and osx has been the best so far for me. it has the capility for doing graphics and be a web server at the same time running like a unix/linux box but with more functionality. as you said u know shit all about mac, you are just assuming that they suck because you never use them.

                Write a Reply...