Hello. I am newly registered here and have been a customer of TCH for a couple years now... I hope someone can help me with my problem. I'm kind of a PHP dunce and what seems to be simple isn't turning out to be so. Here's what I've got:
I am trying to use this script I found to include a certain file based on the current day of the month. So, on the 1st it will include file1.txt, the 2nd will include file2.txt, etc.
I'm including the script on one of my pages so the designated text file will be shown (ideally) on the page for each day of the month. Here's the code...if you see that I've formatted something incorrectly, please help!
--------The Files---------
1- File that calculates: todaysFile.php
2- Result Page - test.php: <? include('todaysFile.php');?>
3- Files to be included: file1.txt, file2.txt, file3.txt, file4.txt, file5.txt, file6.txt, file7.txt
-------------------------------
Here is everything inside todaysFile.php:
<?php
$totalFiles="7"; // Total files to pull from
$todaysFile = Array ( // Up to 31
'1' => 'file1.txt' , // Name of or Path to file
'2' => 'file2.txt' , // Name of or Path to file
'3' => 'file3.txt' , // Name of or Path to file
'4' => 'file4.txt' , // Name of or Path to file
'5' => 'file5.txt' , // Name of or Path to file
'6' => 'file6.txt' , // Name of or Path to file
'7' => 'file7.txt' , // Name of or Path to file
);
// Place day of month in variable 'x'
$x=date("d");
// If value of date exceeds the amount of files then pick a random file to display
if($x > $totalFiles) { $x=rand(1,$totalFiles); }
// Display file
include("$todaysFile[$x]");
?>
And here is the error on test.php when all is said and done:
Warning: main(): Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/blah/public_html/todaysFile.php on line 24
It looks to me like it isn't actually requesting the file to be included...like it can't open a file that isn't named. I know this has got to be something simple but I don't know enough to figure it out. Please help if you can! Thank you so much.
L