Help needed to track down a PHP error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JDJones

    Help needed to track down a PHP error

    A friend just changed servers with her web site. The new server uses PHP
    4.3.2 as opposed to the old server that had one of the 4.0.x's (don't
    remember exactly which one). Now I know all about the register globals
    change but one of the pages is suddenly throwing me an error I can't
    figure out. It is not on a form. It is a script to include a random
    quote on a page once every 50 page loads. It worked fine on the old
    server but is throwing an error on the new one. Can anyone tell me what
    I need to do to correct this?

    The error:

    Warning: fopen(displayqu ote.inc): failed to open stream: Permission
    denied in /usr/local/apache/htdocs/WD/witw/week5.htm on line 129

    Warning: fputs(): supplied argument is not a valid stream resource in
    /usr/local/apache/htdocs/WD/witw/myform.htm on line 130

    Here is the script for it:

    <?
    /* Config Part
    --------------------------------------------------------------------------------------------------------------*/

    $random = false; //true for random, false for sequential $directory = "";
    $quotefile = "randomquote5.i nc"; // The Random Quote file
    $quotecountfile = "displayquote.i nc"; // The Display Quote count file
    that keeps track of what number page load it is

    /* End of Config Part
    -------------------------------------------------------------------------------------------------------*/

    $quotes = file($directory .$quotefile);
    $number = count($quotes);

    if($random){
    $num = rand(0,$number-1);
    }
    else{
    $num = file($directory .$quotecountfil e);
    $num = $num[0]+1;
    if($num>$number-1){ // If ran out of quotes, start again!
    $num=0;
    }
    if (file_exists($d irectory.$quote countfile)) {
    $nu = fopen ($directory.$qu otecountfile, "w"); //This is line 129
    fputs($nu,$num) ; //This is line 130
    }
    else {
    die("Cant Find $quotecountfile ");
    }
    }
    // display the quote on the page
    ?>
    <br>
    <p align="center"> <font face="Verdana, Arial, Helvetica, sans-serif"
    size="2"><b><?p hp print "$quotes[$num]"; ?></b></font></p>



  • Jochen Daum

    #2
    Re: Help needed to track down a PHP error

    Hi JD!

    On Mon, 15 Sep 2003 01:02:27 GMT, JDJones <seebelow@spryn et.com>
    wrote:
    [color=blue]
    >A friend just changed servers with her web site. The new server uses PHP
    >4.3.2 as opposed to the old server that had one of the 4.0.x's (don't
    >remember exactly which one). Now I know all about the register globals
    >change but one of the pages is suddenly throwing me an error I can't
    >figure out. It is not on a form. It is a script to include a random
    >quote on a page once every 50 page loads. It worked fine on the old
    >server but is throwing an error on the new one. Can anyone tell me what
    >I need to do to correct this?
    >
    >The error:
    >
    >Warning: fopen(displayqu ote.inc): failed to open stream: Permission
    >denied in /usr/local/apache/htdocs/WD/witw/week5.htm on line 129
    >
    >Warning: fputs(): supplied argument is not a valid stream resource in
    >/usr/local/apache/htdocs/WD/witw/myform.htm on line 130
    >[/color]
    Its mosty probably a permissioning problem. Whats the user and group
    of the opened file and does the apache user have writing rights to the
    directory?

    HTH, Jochen
    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • JDJones

      #3
      Re: Help needed to track down a PHP error

      Jochen Daum wrote:[color=blue]
      > On Mon, 15 Sep 2003 01:02:27 GMT, JDJones <seebelow@spryn et.com>
      > wrote:
      >[color=green]
      >>A friend just changed servers with her web site. The new server uses PHP
      >>4.3.2 as opposed to the old server that had one of the 4.0.x's (don't
      >>remember exactly which one). Now I know all about the register globals
      >>change but one of the pages is suddenly throwing me an error I can't
      >>figure out. It is not on a form. It is a script to include a random
      >>quote on a page once every 50 page loads. It worked fine on the old
      >>server but is throwing an error on the new one. Can anyone tell me what
      >>I need to do to correct this?
      >>
      >>The error:
      >>
      >>Warning: fopen(displayqu ote.inc): failed to open stream: Permission
      >>denied in /usr/local/apache/htdocs/WD/witw/week5.htm on line 129
      >>
      >>Warning: fputs(): supplied argument is not a valid stream resource in
      >>/usr/local/apache/htdocs/WD/witw/myform.htm on line 130
      >>[/color]
      >
      > Its mosty probably a permissioning problem. Whats the user and group
      > of the opened file and does the apache user have writing rights to the
      > directory?[/color]

      Thank you Jochen. The file's permission was set to 644. By changing it
      to 666, it is working as it should. Funny how it worked on one server
      and not another. Oh well.

      I appreciate your input. I would have been looking for a problem in the
      script or in the PHP setup.


      Comment

      Working...