PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Writing to a server text file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Writing to a server text file

Réponse
 
LinkBack Outils de la discussion
Vieux 10/05/2008, 11h23   #1
kronecker@yahoo.co.uk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Writing to a server text file

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.
  Réponse avec citation
Vieux 10/05/2008, 16h00   #2
AlmostBob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Writing to a server text file

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/win2002/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.


  Réponse avec citation
Vieux 10/05/2008, 16h10   #3
AlmostBob
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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/win2002/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.

>

  Réponse avec citation
Vieux 10/05/2008, 21h06   #4
kronecker@yahoo.co.uk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Writing to a server text file

On May 11, 3:10 am, "AlmostBob" <anonymo...@microsoft.com> wrote:
> 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" <anonymo...@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

>
> > --
> > Adawarehttp://www.lavasoft.de
> > spybothttp://www.safer-networking.org
> > AVG free antivirushttp://www.grisoft.com
> > Etrust/Vet/CA.online Antivirus scan
> >http://www3.ca.com/securityadvisor/virusinfo/scan.aspx
> > Panda online AntiVirus scanhttp://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/win2002/hosts.htm
> > links provided as a courtesy, read all instructions on the pages before
> > use

>
> > Grateful thanks to the authors and webmasters
> > _

>
> > <kronec...@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.


It just prints (the program) it out to the screen and does nothing.
Should it be ran in the cgi directory? I gave it an extension .php

k
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h31.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18833 seconds with 12 queries