Forum Moderators: coopster

Message Too Old, No Replies

How to handle fopen() return value?

         

Twixly

11:56 am on Jan 25, 2007 (gmt 0)

10+ Year Member



Hello.

I am trying to handle the return value of fopen()..

Now here's the problem - I can't access the page myself by browser so I cant simply print it out. The page is set to only accept 3 IP adresses, of which none are mine.

I tried this :

$afile = fopen("logfile.log","w");

$fp = fopen("http://www.example.com?something=anything","r");

fwrite($afile, var_dump($fp));
fclose($afile);
fclose($fp);

Then after that I can FTP the logfile and check it's content for any eventuall errors or return values. But it does not work, I dont know why?

Any ideas. How do I write the content of $fp to a file?

eelixduppy

12:05 pm on Jan 25, 2007 (gmt 0)



If you have no permissions to access the content whatsoever, then you are not going to be able to...

mcibor

12:12 pm on Jan 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think there may be a problem with logging the error. I mean, that your fopen returns an error.

What you can do is log the error reporting as well. More you can find here:

[de.php.net...]

and more about the fopen:

[de.php.net...]

Hope this helps
Michal

Twixly

12:24 pm on Jan 25, 2007 (gmt 0)

10+ Year Member



I do have access to the site in whole with no restriction. But I built the page so that only 3 IP can access it in the future, I want to be able to check on eventuall errors without removing this security.

Thus print the return of fopen() in a file called "logfile.log" or whatever.

The thing is I understand fopen() dont just return errors but any sort of messages that the reciever want to sent, is this wrong?

eelixduppy

9:00 pm on Jan 25, 2007 (gmt 0)




I do have access to the site in whole with no restriction.

Does the server happen to have FTP that you have access to as well? If so, maybe PHP's FTP Functions [us2.php.net] will be of some help. If you did not give yourself permissions to access the website with PHP, then fopen isn't going to work.