here is the code that i have
<?php
$filename = 'shouts.txt';
$somecontent = "&content4=<b><a href=\"mailto:$email?subject=ColdShout\">$nickname</a> - </b>$msg&";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
$count = file_get_contents("count.txt");
$count = explode("=", $count);
$count[1] = $count[1]+1;
$file = fopen("count.txt", "w+");
fwrite($file, "&count=".$count[1]);
fclose($file);
print "count=".$count[1];
?>
This does 2 things
writes
&content4=<b><a href=\"mailto:$email?subject=ColdShout\">$nickname</a> - </b>$msg&
to a text file, and
&count=1
to a nother one.
What i want to do is to have &count=1& in the same file as the other one, and when it is writing the file, this is what i would like it to do
Chek the
1, count number
2, add one to the count number
3, write &content$count=<b><a href=\"mailto:$email?subject=ColdShout\">$nickname</a> - </b>$msg&
Notice, that the content is now the same as the old count number+1
Is this possible,
if so, can anyone post the script, please.
&count=x& should be the first thing in the text file (yes, i do need the & sign at the begining and end of the writes, but count only needs one in the begining, but it would be nice to get one in the begining, and the end.)
Thank you for your time
~Gabor