Persistent Date Stamp - write/read to file
<p>I'm trying to set a persistent date stamp by writing it to a text file and then reading it back in each time the page is viewed.</p>

<pre><code>// set the date, w/in if statements, but left out for brevity
$cldate = date("m/d/Y");
$data = ('clickdate' =&gt; '$cldate');  // trying to set a variable/value pair
 - It's throwing an Error on this !
// Open an existing text file that only has the word "locked" in it.
$fd = fopen("path_to_file/linktrackerlock.txt", 'a') or die("Can't open lock file");
// Write (append) the pair to the text file
fwrite($fd, $data); 
// further down …
// Open the text file again to read from it
$rawdata = fopen("path_to_file/linktrackerlock.txt", 'r');
// Read everything in from the file
$cldata = fread($rawdata, filesize("path_to_file/linktrackerlock.txt"));
fclose($rawdata);
// Echo out just the value of the data pair
echo "&lt;div id='Since'&gt;Clicks Since: " . $cldata['clickdate'] . "&lt;/div&gt;";
</code></pre>
