Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    http://codewalkers.com/tutorials/5/1.html

    I'm using this tutorial to make a news system. The only problem is that it can't write the news.txt file to the directory, even though it's set to 777. I attempted to create the news file on my own, and give it an all access property, but it still can't write to it. Help me please.

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    What happens when you try?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    it just says "Error opening file!"

    According to the php code, this means that the predefined user name and password are correct, but the mistake is in the news.txt file. Since the "a" command opens or writes the file, the problem seems to be that it can't write to news.txt.

  5. #4
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    You know what, I think i'll just change the question: If you have ever successfully set up a news update system on a site using php, please tell me how, since even though I've done exactly what every tutorial has told me to, it still doesn't work. I have MySQL access and php support.

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Why not just use a database? much easier.
    JR

  7. #6
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    I'd prefer to do that, but I can't seem to get that to work either

  8. #7
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    it might not work because safe_mode is on

  9. #8
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    so how do I switch it off?

  10. #9
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    I copied and pasted the tutorial code to my server and tested it.
    I Initially got the same error that you did.

    You can apperantly fix this two ways. You can either put the script in your normal folder, and create the 'news.txt' file in a new subdirectory where you include a new '.htaccess' file with access settings that will override the servers security settings (for that particular folder). You will then have to define a variable and alter the original code'.
    PHP Code:
    $fp fopen('news.txt','a');
    //to this
    $path="complete/path/to/new/folder/news.txt";
    $fp fopen($path,'a'); 
    The problem arises when you try to write to the 'news.txt' file.

    The EASIER fix is to manually create the initial 'news.txt' file (in the same directory as you have placed the tutorial script file in), before you try to write to it. The file doesn't need to contain any text or content, it just have to exist as a file.
    THEN after having created the file, you alter its chmod setting (the 'news.txt' file) to include write permission.
    Now you can read/write to the file to your hearts desire, without generating error messages.

    (BTW you don't HAVE to use 777, you only need to make it read/write enabled which again means that 6 would do the job.)

    In case your unfamiliar with the chmod codes (which is a UNIX file permission level setting), the three digits corresponds to:
    "USER (first digit), GROUP (second digit), OTHER (third digit)" OTHER meaning the rest of the world.

    the access levels are:
    READ(4), WRITE(2), EXECUTE(1).

    A tic mark in only READ, gives the value 4. Tic marks in both READ and WRITE gives 4+2=6. Tic marks in all three permission blocks gives 4+2+1=7.

    All permissions granted to everyone(USER,GROUP,OTHER) will hence give 777.
    S. Rosland

  11. #10
    Member Apocalypse When's Avatar
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    74
    Member #
    1224
    Working!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:49 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com