Jump to content

fopen, fwrite and IP address


webtechatlantic

Recommended Posts

Alright guys, so here is my problem.

 

I have a very simple code i use to track the visitor's which access my website. It works perfectly fine on my own server. A client asked if it was possible for me to track the IP address's of visitors to her site, of course i said yes. Everything went fine for a month, then, all of a sudden the code just stopped working. I am at a complete blank. Here is the code i was using:

 

<?php

 

$ip=$_SERVER['REMOTE_ADDR'];

$data = "$ip,\n";

 

$fh = fopen("pubs.txt", "a");

fwrite($fh, $data);

fclose($fh);

?>

 

Thet text file was named pubs.txt and i changed the persmissions to 666. Is there something I'm missing? The website in question is pyrrole.chemistry.dal.ca. I have a phpinfo at this link, so i know php still works. i can also still get and echo the remote address, i just can't open a file.

 

This is phpinfo: http://pyrrole.chemistry.dal.ca/test/php.php

I also made this test script:

<?php

$myFile = "test.txt";

$fh = fopen($myFile, 'w') or die("can't open file");

$stringData = "Bobby Bopper\n";

fwrite($fh, $stringData);

$stringData = "Tracy Tanner\n";

fwrite($fh, $stringData);

fclose($fh);

 

?>

As you can see by going to http://pyrrole.chemistry.dal.ca/test/test.php, i recieve the can't open file error.

 

Please someone help me, It would be very much appreciated.

 

Thank you very much in advance.

Link to comment
https://forums.phpfreaks.com/topic/131433-fopen-fwrite-and-ip-address/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.