PDA

View Full Version : Really basic ?.



Templarian
August 27th, 2005, 08:52 PM
Okay look below. right now when i send a message with my little program its told to save the data which it does but it just adds onto it.
(text looks like this "&news=hi&news=hi im doing good&news=hi im doing good nice)

is there anything i have to change to the server (i allowed the .txt to be written to so i dont get why the file content cant be deleted if it can be added too.)

<?
$myfile = file("news.txt");
$fh = fopen("news.txt","a");
//unlink($myfile); i dont know what to do with this unlink thingy.
//use a+ to add to old text. i think
fputs($fh, stripslashes("&news=$news"));
fclose($myfile);
?>

thx.

pbrollwitme
August 27th, 2005, 08:59 PM
do you want to rewrite over what already exists? If so, use w+ instead of a in the $fh = fopen("news.txt","a");

pbrollwitme
August 27th, 2005, 09:01 PM
this describes the letters used in that script: http://www.w3schools.com/php/php_functions2.asp

Templarian
August 27th, 2005, 09:02 PM
ur a freaken genius. Thank you so very much i've been trying to do this for an hour and a half.

//edit and you can read minds i was just about to look for a list.

pbrollwitme
August 27th, 2005, 09:04 PM
haha...glad i could help