Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using php to write to a txt file

Status
Not open for further replies.

gameon

Programmer
Feb 23, 2001
325
GB
Hi does anyone know how I can write to a text file, using php.

There some variables in the flash file:

eg:

Location=150;

I would like to click a button and update a txt file that used to say:

Location=100;

Is this possible?

Cheers,

M@
 
you can rewrite it :
$fp = fopen($yourfile, "w");
fwrite ($fp,$yourdata);
fclose ($fp);

read the doc on fopen to know all about the options ("w" is for write only and it removes what was previously in the file - if there was something in it)
 
Hi (im not too experienced)

The flash file stores three vars:
Loaction1
Location2
Location3

I set the values of these vars in flash, click update.
(posting the vars to the php file)

The php file updates the vars in the text file to be whatever they have been set to in the flash file. eg

Loaction1=150
Location2=200
Location3=300



The php file would be:
<?php

$fp = fopen(var.txt, &quot;w&quot;);
fwrite ($fp,var1=$var1value;);
fclose ($fp);

?>

The txt file would now look like:

Loaction1=150
Location2=200
Location3=300
 
The php file would be:
<?php
$fp = fopen(var.txt, &quot;w&quot;);
fwrite ($fp,var1=$var1value;);
fclose ($fp);
?>

The txt file would now look like:
var1=<whtever you passed as $var1value>;
so it's not what you want
(why didn't you TRY this anyway ????)

try :
...
fwrite ($fp,&quot;Location1=&quot;.$value_for_location_1);
fwrite ($fp,&quot;Location2=&quot;.$value_for_location_2);
fwrite ($fp,&quot;Location3=&quot;.$value_for_location_3);
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top