SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Script does not complete

    I use php to show a friendly version of my server logs. Works nicely, until it doesn't
    The problem occurs when the log gets very large. My script reads the logs line by line, using a 100-line buffer. Nothing particularly memory-intensive. But the script will just inexplicably stop in the middle of execution. When I suspend output during execution, the script returns a 500 error. When I try to establish exactly where execution stops, the answer is: nowhere in particular - the script stops at different points within the code at different times (even with the same log file as its input). I've checked allocated memory usage, and it's nowhere near the set memory limit. Likewise, execution time is nowhere near the maximum allowed. Any ideas on what's causing the problem?
    Thanks much
    Rob

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    sporadic script error

    Hi robbroekhuis, welcome to the forums,
    ... Any ideas on what's causing the problem? ...
    One of the file system functions that's used is the wrong choice? It may help if you post some of the relevant code.

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the welcome
    One of the file system functions that's used is the wrong choice?
    I don't think so. One of the first things I did in trying to troubleshoot the code was just getting the script to output the raw log file (as a query-string option). The code:
    Code:
          while (!feof($handle)) {
             $s=fgets($handle);
             echo "$s<br>";
          }
    works just fine. The real version uses essentially the same file system functions (and shares the same code to open the file in the first place), but in a more distributed fashion. But the stronger reason why I'm not inclined to blame file functions is that it's not at any particular operation (including file access) that execution halts. That's also why I'm hard-pressed to post any "relevant code", although I'd gladly post a link to the whole thing, if anybody would bother to actually look at it
    I failed to mention yesterday that I tried this in both php4 and php5 environments (my script works in both), and get the same behavior.
    Rob

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,228
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    errors

    Your snippet shows that when an error occurs the code will exit the while loop. What error messages are you getting?

  5. #5
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have my error_reporting set to E_ALL, but get no errors or warnings.


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
  •