1

I am trying to adapt a calendar script by David Walsh. In David's script showing a monthly calendar, for the first week it shows blanks before the month start but a commenter said you can use following code to display the dates from the previous month ie 28 20 30 depending on when the first day of the month falls.

I won't repeat all of the code from the script linked to, but the main thing is that the replacement code displays a symbol I have never seen before.., �30�. (I have copied these symbols from he source. They are squares that say FF above PD.). Here is code. Note $x, $running_day and $daysInThisWeek are just numbers. $calendar gets echoed at end.

//following prints out empty table cells

for($x = 0; $x < $running_day; $x++):
        $calendar.= '<td class="calendar-day-np">&nbsp;</td>';
        $days_in_this_week++;
    endfor;
echo $calendar;

//But following, echoed, prints out weird symbols:

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year));

Then when you loop through as above you get a whole bunch of the weird symbols.

for($x = 0; $x < $running_day; $x++): //this line is same as above
$calendar.= ' . ( ( $daysInLastMonth – ( $runningDay – 1 ) ) + $x ). ';
$daysInThisWeek++;
endfor;
echo $calendar;

Does anyone know what might be going on, what the weird symbols mean and how to get this to display properly.

Thanks for any suggestions!

wohlstad
  • 12,661
  • 10
  • 26
  • 39
user1904273
  • 4,562
  • 11
  • 45
  • 96

2 Answers2

2

Turn on all errors and you will see that you have wrong quotes. Errors would be like

Notice: Use of undefined constant ‘t’ - assumed '‘t’'

This line

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year));

must be

$daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year));
sectus
  • 15,605
  • 5
  • 55
  • 97
  • Wow. Thanks. I don't know how long it would have taken me to figure that out. Changed the punctuation and that fixed it. Thx. Will mark correct when it lets me. – user1904273 May 14 '13 at 00:17
2

There is a mistake with:

$daysInLastMonth = date(‘t’,mktime(0,0,0,$month-1,1,$year));

It should be:

$daysInLastMonth = date('t',mktime(0,0,0,$month-1,1,$year));

To notice that kind of mistake you have to turn on errors:

error_reporting(E_ALL);

More information about PHP errors in: http://php.net/manual/en/function.error-reporting.php

About the characters it seems to be a encoding issue:

These links will help you:

http://www.php.net/manual/en/ini.core.php#ini.default-charset

UTF-8 all the way through

Community
  • 1
  • 1
chaim
  • 1,236
  • 2
  • 14
  • 16