Page 1 of 1
What am i doing wrong? :-(
Posted: Mon May 06, 2002 3:59 pm
by hob_goblin
Code: Select all
<?PHP
if(isset($screenname)){
$TheFile = "sn.txt";
$Open = fopen ($TheFile, "a+");
$replaceit = fread($Open, filesize ($TheFile));
$replaceit_2 = ereg_replace("$screenname", "", $replaceit);
fwrite($Open, "$replaceit_2");
fwrite($Open, "$screenname");
fclose ($Open);
}
include("sn.txt");
?>
what is wrong with this code? i want it to log the "screenname" var in a text file, but i want it to check if its there already, and if it is, i dont want it to write it over again...
its probably something stupid, but what can i say, i've only been learning for like a week

Posted: Mon May 06, 2002 7:15 pm
by hob_goblin
anybody?
Posted: Mon May 06, 2002 8:09 pm
by phice
Are you sure you've CHMOD'd the file to 666? If not, do so.
Posted: Mon May 06, 2002 9:09 pm
by hob_goblin
i chmoded it to 777, but the problem im having is it keeps writing the name in, even if its already in there
Posted: Mon May 06, 2002 11:01 pm
by phice
Try to CHMOD it to 666, and re-run the program, and see if it works.
Posted: Mon May 06, 2002 11:48 pm
by dusty
Code: Select all
<?
$array = file('sn.txt');
if(!in_array("$screenname
", $array)) {
put it there;
}
?>
chmoding to 666 shouldn't make a difference if he already set 777
Posted: Tue May 07, 2002 2:38 pm
by hob_goblin
Posted: Tue May 07, 2002 3:24 pm
by dusty
my method is assuming your text file looks like
----------------
blah
blah
blah
name
blah
blah
----------------
Posted: Tue May 07, 2002 4:31 pm
by hob_goblin
ok i got it to work, using $HTTP_GET_VARS["var"]
but whenever it logs to the file it writes:
Person'sname HTTP 1.x
any way to change this?
Posted: Tue May 07, 2002 5:33 pm
by hob_goblin
never mind, i just used ereg_replace

Re: What am i doing wrong? :-(
Posted: Thu May 09, 2002 5:53 am
by prasadharischandra
u have to use Unlink fuction and replace new text file where u want
Posted: Thu May 09, 2002 10:39 am
by dusty
what??
Posted: Thu May 09, 2002 10:23 pm
by prasadharischandra