Alright, I've been searching the internet for hours, so now I come to you guys for help. My code is below, but to summarize what's going on, when I use
fwrite($file, "Hello!");
it writes "Hello!" just fine. But yet if I do this:
$text = "Hello!";
fwrite($file, $text);
it won't write anything to the file at all. I've tried enclosing $text in quotes and not, and it doesn't make a difference. Here is the exact php code I am using (and yes the variables are posted to it, and if I simply print them on the page, it works).
<head>
<?php
$date = $_POST['date'];
$title = $_POST['title'];
$announce = $_POST['announce'];
$firstName = $_POST['firstName'];
$output = "\n".$date." | ".$title." | ".$announce." | ".$firstName;
function writeIt(){
$your_data = "\n".$date."|".$title."|".$announce."|".$firstName;// Open the file and erase the contents if any
$fp = fopen("announcements.txt", "a+");// Write the data to the file
fwrite($fp, $your_data);// Close the file
fclose($fp);
}//writeIt
?>
</head>
<body onUnload="<?php writeIt(); ?>">