fopen question

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

    #1

    fopen question

    Hi,
    I want to open a file for debugging purposes and want to know how I can
    access it (write to it) from across multiple php files. I want to be
    able to write debugging information from within multiple php files. Can
    I store the file locally or does it have to be on the server? My php
    files are a web hosting company's server.

    I tried to store the file pointer returned by fopen as a session
    variable. I get a warning: fopen (http://www.mydomain.com/somedir/debug)
    failed to open stream: HTTP wrapper does not support writeable
    connections.
    Thisis followed by a bunch of:
    warning: fwrite(): supplied argument is not a valid stream resource


    if (!isset($_SESSI ON['fh'])) {
    $fh = fopen("http://www.mydomain.co m/somedir/debug", "w");
    $_SESSION['fh'] = $fh;
    }
    ......
    ......
    fwrite($_SESSIO N['fh'], "\nsome debugging text \nmsg: ".$msg."msg_typ e:
    ".$msg_type );


    Thanx.


  • Pedro Graca

    #2
    Re: fopen question

    Xerxes wrote:[color=blue]
    > I want to open a file for debugging purposes and want to know how I can
    > access it (write to it) from across multiple php files. I want to be
    > able to write debugging information from within multiple php files. Can
    > I store the file locally or does it have to be on the server? My php
    > files are a web hosting company's server.[/color]

    See error_log() function.

    [color=blue]
    > I tried to store the file pointer returned by fopen as a session
    > variable.[/color]

    fopen() returns a resource. Resources are not serializable, therefore
    not saved in session variables.


    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    Working...