Connecting Tech Pros Worldwide Help | Site Map

fopen question

Xerxes
Guest
 
Posts: n/a
#1: Jul 17 '05
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($_SESSION['fh'])) {
$fh = fopen("http://www.mydomain.com/somedir/debug", "w");
$_SESSION['fh'] = $fh;
}
......
......
fwrite($_SESSION['fh'], "\nsome debugging text \nmsg: ".$msg."msg_type:
".$msg_type);


Thanx.


Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

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.
http://www.php.net/error_log
[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 :
Closed Thread


Similar PHP bytes