Problems with date arrays
Posted: Fri Jan 03, 2003 2:13 pm
I am builing a calendar based on a tutorial from web calendar. it seems to be going OK except where there is no records for a month it generates errors saying:
Warning: Wrong datatype for second argument in call to in_array in /var/www/webhosts/web.com/httpdocs/support/desk/calender.php on line 37.
I believe the problem is where there is no records returned for that month either nothing or 0 is being used to compare against the month array. How can I get round this? Do I just use an if/else statement to create a dummy date (ie. 0000-00-00) if a result is not returned? Please find following code.
Calendar function
Warning: Wrong datatype for second argument in call to in_array in /var/www/webhosts/web.com/httpdocs/support/desk/calender.php on line 37.
I believe the problem is where there is no records returned for that month either nothing or 0 is being used to compare against the month array. How can I get round this? Do I just use an if/else statement to create a dummy date (ie. 0000-00-00) if a result is not returned? Please find following code.
Code: Select all
<?php
include "calender.php";
$query = "SELECT dayofmonth(cal_date) as cal_date
FROM cal_entry
WHERE year(cal_date)='$year' and month(cal_date)='$month'";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result)) {
$dateArray[] = $row['cal_date'];
}
?>Code: Select all
<?php
if (in_array($currentDay,$dateArray)) {
$date = "$year-$month-$currentDay";
$calendar .= "<td class='linkedday'>
<a href='webcal.php?date=$date'
class='calendarlink'>$currentDay</a></td>";
} else {
$monthday = "$year-$month-$currentDay";
$calendar .= "<td class='day'>
<a href='webcal.php?date=$monthday'
class='calendarlink'>$currentDay</a></td>";
}
?>