Connecting Tech Pros Worldwide Help | Site Map

fopen question

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:18 AM
Xerxes
Guest
 
Posts: n/a
Default 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($_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.



  #2  
Old July 17th, 2005, 04:18 AM
Pedro Graca
Guest
 
Posts: n/a
Default 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 :
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.