I am trying to make an events calender with PHP. Although the calender seems to be working fine, all the months and dates etc, but the following error is displayed:
ERROR: Couldn't create events file."); @fclose($fp); } $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb") or die("ERROR: Couldn't open events file to read events."); >?
I have the following line of code right in the beginning of my code
echo define("EVENT_FILE", "cal_events.text");
and to read events of a month, i have the following code which obviously doesnt work cause the file has not been created
function ReadEvents($Month)
{
$theEvents = array();
$eventCounter = 0;
if(!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE))
{
$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "w")
or die("<span class='error'>ERROR: Couldn't create events file.</span>");
@fclose($fp);
}
$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb")
or die("<span class='error'>ERROR: Couldn't open events file to read events.</span>");
As I am only a beginner, I am sure there is something wrong with the code. Can someone please identify?