Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    66
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Handling file-read failure

    I'm kinda new with php, but I'm dying to know how to do the following. But can't seem to get the syntax right. Here's the pseudo code...

    Page Refresh = 30 secs
    --Read file-a.txt
    --file-a.txt not available?
    ----read file-b.txt
    ----file-b not available?
    ------do nothing... (page will refresh in 30 secs and repeat the process)


    The problem:
    =======================
    I have a lot of visitors accessing my site and a lot of times the page becomes inaccessible if it refreshes at just the right (wrong) time while it's being read/written to. Instead of the page locking up or giving a server error, I want to be able to try to read a secondary file as a backup.

    How can I achieve the logic above?


    Thanks for your help!

    Elliott

  • #2
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    You can lock files with flock().
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


  •  

    Posting Permissions

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