You should check your file "quote.txt" really only have contents
QUOTE
I really cant say wherefrom came '?>'
in output
?>QUOTE
I think this wont work:
$currentdate = date("m.d.Y");
see function [man]date[/man]
it takes a second parameter, usually time()
= current time in seconds
okay, you are right:
if there is no second parameter, then is assumed current time
which is = time()
so
$currentdate = date("m.d.Y");
will work!
1) I Turned ON full debug error_reporting on line 2
You have to make these following changes, 2) 3)
2) if($contents = $currentdate) should be if($contents == $currentdate)
3) if($day = "Monday" && should be if($day == "Monday" &&
4) I added an exit; for // If today isn't Sunday
<?php
error_reporting(2047); // = (E_ALL); debug setting
// ########################
// Quote of the Week script
// ########################
include("config.php"); // Include configuration file
$currentdate = date("m.d.Y"); // Find today's date
$day = date("l"); // Find the day of the week
$read = fopen("date.txt","r"); // Open date.txt to read
$contents = fread($read,filesize("date.txt")); // Read date.txt
if($contents = $currentdate) { // If date.txt's date = today...
$rewrite = "0"; } // don't make a new quote
else {
$rewrite = "1"; } // Else do make a new quote
fclose($read); // Close date.txt
if($day = "Monday" && $rewrite == "1") { // If today is Sunday and the quote hasn't yet been changed... SET TO MONDAY FOR TESTING PURPOSES
$range = count(scandir('quotes')-1); // Find the number of quotes
$rand = rand(0,$range); // Choose random number
$randqotw = "quotes/qotw".$rand.".txt"; // Generate txt name
$file = fopen("quote.txt","w"); // Open quote.txt to write to
fwrite($file,$randqotw); // Write the random quote chosen to quote.txt
fclose($file); // Close quote.txt
$file2 = fopen("date.txt","w"); // Open date.txt
fwrite($file2,$currentdate); // Write today's date to date.txt
fclose($file2); // Close date.txt
include("quote.txt"); // Display quote
exit; // Exit
}
else { // If today isn't Sunday and/or it's already been written...
include("quote.txt"); // Display quote
exit; // added Exit
}
// exit; // two previous exits could be replaced by one here
?>