SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    fopen problem, "w" does not work

    Hi!

    I'm new to php and I need help with my simple script:

    <?php
    $handle = fopen("bosko.txt", "r");
    $contents = "";
    while(!feof($handle)){
    $contents .= fread($handle, 1000);
    }
    fclose($handle);
    $firstrep = str_replace(" ", "", $contents);
    $newphrase = str_replace(",", " ", $firstrep);
    $fh = fopen("bosko.txt", "w");
    fwrite($fh, $newphrase);
    fclose($fh);
    ?>

    I want to open "bosko.txt", to modify it (this part is working) and then to write modified version back to file (this part is NOT working).
    All I get is:

    Warning: fopen(bosko.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\lilypond compiler\02.php on line 10

    Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\lilypond compiler\02.php on line 11

    Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\lilypond compiler\02.php on line 12


    I'm running PHP 5, on localhost IIS 6, WinXP.

    Thanks in advance.

    Waiting for your help....

    Bosko

  2. #2
    SitePoint Enthusiast Gods Lonely Man's Avatar
    Join Date
    Sep 2006
    Location
    Yes
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The webserver doesn't seem to have any writing rights for that file.
    Try chmodding bosko.txt to 777
    I have no capslock and I must scream....

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but I did some reading about chmod and found out that it's not for Windows.
    I was trying some alternative things like changing permissions for folder but it didnt help.

    Do you have any other idea?

  4. #4
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Warning: fopen(bosko.txt) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\lilypond compiler\02.php on line 10

    The error is exactly what it says. It's a permissions issue. If you can't chmod, it's something else. This is the exact error you get when there is not proper permissions set on a file.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but how to set permissons for file?
    I've tryed it in IIS but nothing again....

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I solved my problem with turning off simple sharing in folder view.
    Anyway, thanks for help.

    Bosko


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •