In general I found chapter 5 to be pretty good.
I got it up and running without too much
trouble.
Now, there are some errors and I have some
comments.
ISSUE #1
notify.php - page 129
The section "Sending Reminders"
The notify.php code in the gray box
The 7th line down is missing ending single quote on
the actual email address.
This is wrong in the book and in the download code.
(note the download code has different email address,
but they still forgot the single quote at the end).
in the book
and in the download code
It should be like
ISSUE #2
notify.php - page 130
notify.php, in the first gray box where it says mail,
mgs should be msg. This is wrong in both the book and download code
The book has it like this.
Code:
mail(EMAIL_ADDR, "Reminders for $month/$day/$year $hour:$minute $am", $mgs);
It should be like this, (msg instead of mgs)
Code:
mail(EMAIL_ADDR, "Reminders for $month/$day/$year $hour:$minute $am", $msg);
ISSUE#3
notify.php - comments on time iterval
I have some comments regarding the time interval given
in the retrieve upcoming events query
(page 129, gray box, about 19th line down)
Code:
$year, $month, $day, $hour, $minute,
$year, $month, $day + 5, $hour, $minute + 15);
It checks events between right now and 15 minutes from now.
That does not give you much time to get to your appointment! :)
I guess it depends on what you are doing.
It also makes testing difficult.
I changed it to day + 1 to make my testing easier
Code:
$year, $month, $day, $hour, $minute,
$year, $month, $day + 1, $hour, $minute);
A couple of things about the cron job.
1. Your cron job would have to be run less than 15 minutes apart otherwise
you would miss some of the events.
2. Your cron job would have to run as far away from the start time as
possible, like 9:01. If you ran it at 9:13 lets say, you'd only have
2 minutes to get to your appointment!
There is nothing wrong with the code. It's up
to us to set the time interval and make sure the
cron jobs are run at the proper times.
ISSUE # 4
calendar.php - boundary issues concerning DAY_HR_END
DAY_HR_END is set to 17
page 124, lower gray box, about line 9
Code:
define('DAY_HR_END', 17);
The code loops through and gets events all the
way up to 5:59 PM
page 126, gray box, lines 1-4
Code:
// output cells
for ($i = DAY_HR_START; $i <= DAY_HR_END; $i++)
{
for ($j = 0; $j < 60; $j += 15)
{
I guess this is okay if you want to include the last
hour. If you did not want to include the last hour all
you would have to do is change $i <= DAY_HR_END to
$i < DAY_HOUR_END
One of the reasons I bring this up is because there is an inconsistency
with figures 5-3 on page 134, and figure 5-4 on page 135.
These figures are showing calendars after import.
(Microsoft Windows Calendar and Mozilla Thunderbird)
In both these figures the time slots are grayed out after 5:00 PM.
They also show it starting at 8:00 am. This is inconsistent
with our other calendar.
ISSUE # 5
calendar.php - The "Also Scheduled" section.
The query gets events outside the DAY_HR_START and DAY_HR_END,
by using the clause WHERE EVENT_TSTAMP NOT BETWEEN.
This is fine, but it goes too far as it gets events outside the
current day. An event five months before the DAY_HR_START will
get listed here; same for events after DAY_HR_END.
Perhaps it would be better to get events between midnight
and DAY_HR_START and between DAY_HR_END and midnight for
the day chosen.
I changed my code to do it this way.
(note: concerning the boundary issues stated above.
I am doing like the book does it here and including
events in the 5:00 o'clock hour, that is, events all
the way up to 6:00pm).
Code:
$query = sprintf('SELECT EVENT_NAME, UNIX_TIMESTAMP(EVENT_TSTAMP) AS ' .
'EVENT_TSTAMP FROM CALENDAR WHERE EVENT_TSTAMP ' .
'BETWEEN "%4d-%02d-%02d 00:00:00" AND "%4d-%02d-%02d %02d:59:59" OR ' .
'EVENT_TSTAMP BETWEEN "%4d-%02d-%02d %02d:59:59" AND "%4d-%02d-%02d 23:59:5
9" ' .
' ORDER BY ' .
'EVENT_TSTAMP ASC, EVENT_NAME ASC',
$year, $month, $day,
$year, $month, $day, DAY_HR_START -1,
$year, $month, $day, DAY_HR_END,
$year, $month, $day );