View Single Post

  #3 (permalink)  
Old 05-10-2008
AlmostBob
 
Posts: n/a
Default Re: Writing to a server text file

Mine looks like this

<?php
// Get user stats.
$getdate = date( 'd-m-Y, H:i:s' ); // Get the date & time.
$user_ip = $_SERVER['REMOTE_ADDR']; // Get the users IP.
$user_browser = $_SERVER['HTTP_USER_AGENT']; // Get the browser type.
$referer = getenv("HTTP_REFERER"); // Get the refering page.
// Look for the text file and open it for writing.
$file = "./logfiles/logfile.csv";// define the file. in a different folder,
..csv -import into excel
$fp = fopen($file, "a+");//open the text file for writing.
// Write the user stats into the text file.
fputs ($fp, "$user_ip,$getdate,$user_browser,$referer\n");
fclose($fp);// Close the text file.
?>

look for 'bbclone the web page counter on steroids' nothing to do with me,
but great if you cant access server logs on your host plan

"AlmostBob" <anonymous1@microsoft.com> wrote in message
news:dMiVj.1794$KB3.1056@edtnps91...
> Try renaming index.html to index.php
> That way php will know that there is something for it to do
> the script will be ignored in an html file
>
>
> --
> Adaware http://www.lavasoft.de
> spybot http://www.safer-networking.org
> AVG free antivirus http://www.grisoft.com
> Etrust/Vet/CA.online Antivirus scan
> http://www3.ca.com/securityadvisor/virusinfo/scan.aspx
> Panda online AntiVirus scan http://www.pandasoftware.com/ActiveScan/
> Catalog of removal tools (1)
> http://www.pandasoftware.com/download/utilities/
> Catalog of removal tools (2)
> http://www3.ca.com/securityadvisor/n...aspx?CID=40387
> Blocking Unwanted Parasites with a Hosts file
> http://mvps.org/winhelp2002/hosts.htm
> links provided as a courtesy, read all instructions on the pages before
> use
>
> Grateful thanks to the authors and webmasters
> _
>
>
> <kronecker@yahoo.co.uk> wrote in message
> news:6c7f789a-62bc-4cba-9754-1ef5ac4ad0c3@a9g2000prl.googlegroups.com...
>> I have this
>>
>> <html>
>>
>> <head>
>> <title>My Program</title>
>> </head>
>>
>>
>> <body>
>> <div>
>> <?
>>
>> $file = ("remote.txt"); //file where data is stored
>> Print "Writing to $file "
>> $fp = fopen($file , "w"); //open the file for write
>> fputs($fp , "my text here"); //write the new value to the
>> file
>>
>> fclose($fp); //close the file
>>
>>
>> ?>
>> </div>
>> </body>
>>
>>
>> </html>
>>
>> which runs nothing happens to the text file remote.txt - it remains
>> empty.
>> I suppose it could be its permissions - how to change these - this is
>> not a Unix system or at least I don't have access to the chmod
>> command. Or could there be something else wrong with my script? Should
>> the text file appear in the same directory? I created it myself and it
>> stays empy. Is this all I need for PHP or must I put it in a special
>> directory. This is an index.html file.
>>
>> Thanks
>>
>> K.

>

Reply With Quote