note 35016 rejected from function.fwrite by didou
| From: | didou@php.net | Date: | Fri, 15 Aug 2003 16:50:53 +0000 |
| Subject: | note 35016 rejected from function.fwrite by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54224@lists.php.net to get a copy of this message | ||
Note Submitter: cwytch@cox.net
----
i used this im makeing a messageboard by text with this
what i want to do is insted of it printing Add this to the file
i want it to post what ever the person has typed how would i do that here is the code
<?php
$filename = 'messageboard.txt';
$somecontent = "<br> Add this to the file\n";
// 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')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
print "The file $filename is not writable";
}
?>