Forum Moderators: coopster

Message Too Old, No Replies

Reading a file

Works locally, does not on remote

         

ukgimp

10:23 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have the following script that opens up a file on apache and later on finds all the referrers. When I do things locally after having saved a copy of the log file as a text file thing work fine. However when I upload and change the script things don work at all. The folder in which the logfiles are stored have read permissions. All I get is blank page. Any ideas?

//$todaylog = "/usr/local/home/httpd/logs/asite/access_log";
$todaylog = "c:/phpdev/www/folder/access_log.txt";

$referers = array();

$fd = fopen("$todaylog","r");

percentages

10:30 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm no PHP expert but this works for me:

$log = file("/home/somesite/logs/access_log");

ukgimp

10:57 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK at least I am getting an error now with the change you suggest appart from the path change:

Warning: file(/usr/local/home/httpd/logs/mysite/access_log.txt): failed to open stream: No such file or directory in /mypath/script.php on line 8

I have tried both access_log and access_log.txt

Flummoxed, UK

percentages

11:08 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My best guess is the path is wrong:

/usr/local/home/httpd/logs/mysite/

doesn't look like a typical path.

maybe: /usr/local/home/mysite/httpd/logs/

Best to check with the host the actual path to the home directory and the logs directory. But normally the "mysite" directory would be further up the tree.

ukgimp

11:17 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



the mysite bit might be a bit midleading, that is simply a folder name where I store the logs for that particular virtual site. I copied the path from the nav bar in my FTP client.

should I be calling the file itself and is is possible that they are not called .txt in the server?

ukgimp

11:27 am on Jan 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Solution

File name wrong

Lesson learned, check the filename. access.log not .txt.

Thanks for your help