I've read the documentation at php.net for readline and fopen, and it makes sense. However, my file isn't opening.

I don't know why, but I think it might be because of the way I've written the location of the file. it's on the desktop.
I called the script nameFetcher.php and I wrote in it:

$fd = fopen("c:\WINDOWS\Desktop\names.txt", "r");

echo "$fd";

I get something like : Resource id 23492

Then I switched it to:

$fd = fopen("c:\Desktop\names.txt", "r");

echo "$fd";

and i get a parse error that says that "c:\Desktop\names.txt" doesn't exist in the place where I save my php scripts. which is something like, c:\Program Files\Apache Group\Apache\htdocs

and so I save names.txt in that place also, and change the location to in the fopen function to:

c:\Program Files\Apache Group\Apache\htdocs

that doesn't work.

Can someone tell me what I'm doing incorrectly? Thanks.

    check the path to be absolutely sure that it is correct...

    desktop path is usually longer

    use windows explorer to get the true path and try that...

      It is definitely longer? Depending on which version of windows you are using it is different...

      For XP it is...

      C:\Documents and Settings\username\desktop

      Try putting the txt file in the root of C: and use...

      if(!($myfile = fopen("c:\test.txt", "r")))
      {
      echo "Can't open file";
      }

        Also you are forgetting to put a \ after c:
        That is not your problem but would cause one if you had the correct path.

        Deo

          Well, I'm using Windows 98 SE, and I right clicked the document, and checked Properties, and it said the location was:

          C:\WINDOWS\Desktop

          which would then make the full path for my text file to be:

          c:\WINDOWS\Desktop\names.txt

          right?

          Back to square one.

          EDIT:

          I used that path again, and it didn't seem to work. I had been getting "Resource id #1" Then I added a while loop and it worked perfectly...kindof.

          The new question is this:

          This text file is source code from an HTML page. When I open the file, I expect to see the source code displayed, instead, it displays the HTML page, ie., the tables and colors and formatting, whereas I just want the source code. Here is my code:

          
          <html>
          <head><title></title></head>
          <body>
          <?php
          $fd = fopen ("c:\WINDOWS\Desktop\scoreboard[1].txt","r");
          $boxcoreURLs = array();
          while (!feof ($fd)) 
          {
             $buffer = fgets($fd, 4096);
             echo ("$buffer");
          }
          echo ("$fd");
          ?>
          </body>
          </html>
          
          

          Can someone tell me how to just get the source code displayed? Eventually, I want to search the file for some URLs and stick them into an array, if that helps any. Thanks.

            show your code

            it should read
            $fd = fopen("c:\WINDOWS\Desktop\names.txt", "r");

              The code seems to work now, as far as getting something to open, but what opens is an html page, with all the formatting. What I want is the source code.

              
              
              <html>
              <head><title></title></head>
              <body>
              
              <?php
              $fd = fopen ("c:\WINDOWS\Desktop\names.txt","r");
              $boxcoreURLs = array();
              while (!feof ($fd)) {
              $buffer = fgets($fd, 4096);
              echo ("$buffer");
              }
              
              echo ("$fd");
              
              ?>
              
              </body>
              </html>
              
              
                Write a Reply...