madspof Posted May 20, 2009 Share Posted May 20, 2009 Hi everyone I have been trying to get a calendar entry system to work with error reporting on but to no avail, the problem lies in the part of highlighted below. And for some reason it tells me that it is undefined and no matter what ive tried i cannot get it to be define. anyway here is a the code below and here is a link to the effect script www.deskfun.co.nr/1123 hooton park squadron/calendar/ you will need to use the username: Testing and password: squadron. Its line 226 which brings the error message up Sorry about the large amount of code but i dont know which part of it is affecting it :-( and thanks before hand :-) <?php class myEventsCalendar { var $month = 0; var $day = 0; var $year = 0; var $Months = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var $overlibPath = ""; var $eventsId = array(); var $eventsData = array(); var $eventsCount = 0; var $formDetailsAction = ""; function myEventsCalendar($thisFormDetailsAction) { //set the destination to view event details $this->formDetailsAction = $thisFormDetailsAction; //set additional parameters if necessary //need to set month, day, and year //before generating HTML $this->eventsData = array(); $this->eventsCount = count($this->eventsData); } /**Append the parameter element to the vector*/ function addEvent($thisDate,$thisEventTitle, $thisEventTime, $thisEventDescription) { if(!empty($thisDate)) { $dateArr = explode("-",$thisDate); $mIndex = intVal($dateArr[0]); $dIndex = intVal($dateArr[1]); $yIndex = intVal($dateArr[2]); $dateIndex = $mIndex . "-" . $dIndex . "-" . $yIndex; if(!$this->eventsId[$dateIndex]) { $this->eventsId[$dateIndex] = 1; } else { $numOfEvents = intVal($this->eventsId[$dateIndex]); $numOfEvents = $numOfEvents + 1; $this->eventsId[$dateIndex] = $numOfEvents; } $titleIdx = "title" . $this->eventsId[$dateIndex]; $timeIdx = "time" . $this->eventsId[$dateIndex]; $descrIdx = "description" . $this->eventsId[$dateIndex]; $this->eventsData[$dateIndex][$titleIdx] = $thisEventTitle; $this->eventsData[$dateIndex][$timeIdx] = $thisEventTime; $this->eventsData[$dateIndex][$descrIdx] = $thisEventDescription; $this->eventsCount = count($this->eventsData); return true; } else return false; } function setMonth($thisMonth) { $this->month = $thisMonth; } function setYear($thisYear) { $this->year = $thisYear; } function setDay($thisDay) { $this->day = $thisDay; } function setOverlibPath($thisPath) { $this->overlibPath = $thisPath; } function getDayOfMonth($month, $day, $year) { $myresult = date("l", mktime(0, 0, 0, $month, $day, $year)); return $myresult; } function getMonthName($month, $day, $year) { $myresult = date("F", mktime(0, 0, 0, $month, $day, $year)); return $myresult; } function getWeekDay($day) { $myresult = 0; switch ($day) { case "Monday": $myresult = 1; break; case "Tuesday": $myresult = 2; break; case "Wednesday": $myresult = 3; break; case "Thursday": $myresult = 4; break; case "Friday": $myresult = 5; break; case "Saturday": $myresult = 6; break; case "Sunday": $myresult = 7; break; } return $myresult; } function getNumDaysOfMonth($month, $year) { // non-leap year $nonleap = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); // leap year $leap = Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $isLeap = false ; if (($year % 4) == 0) { if (($year % 100) == 0 && ($year % 400) != 0) { $isLeap = false; } else { $isLeap = true; } } else { $isLeap = false; } if($isLeap == true) { return $leap[$month - 1]; } else { return $nonleap[$month - 1]; } } function isToday($month,$day,$year) { if( ($month == intval(date("m"))) && ( $day == intval(date("d"))) && ($year == intval(date("Y")))){ return true; } else { return false; } } function getDetails($thisDate, $allDetails) { $counter = 1; $titleIdx = "title" . $counter; $timeIdx = "time" . $counter; $descrIdx = "description" . $counter; $result = ""; //prepare overlib data while($this->eventsData[$thisDate][$titleIdx] != "") { if($counter > 1){ $result .= "<br><br>"; } $result .= "<b>Event:</b> " . $this->eventsData[$thisDate][$titleIdx]; $result .= "<br><b>Time:</b> " . $this->eventsData[$thisDate][$timeIdx]; if($allDetails) { $result .= "<br><b>Description:</b> " . $this->eventsData[$thisDate][$descrIdx]; } $counter = $counter + 1; $titleIdx = "title" . $counter; $timeIdx = "time" . $counter; $descrIdx = "description" . $counter; } return $result; } function outputDay($thisMonth,$thisDay,$thisYear) { $thisDate = ""; $thisDate = $thisMonth . "-" . $thisDay . "-" . $thisYear; $ch = "eventsId[$thisDate]"; if($this->eventsId[$thisDate]) { $overlib = $this->getDetails($thisDate, false); $details = $this->getDetails($thisDate, true); echo "<a href=\"javascript:goToDetails('" . urlencode($details) . "')"; echo ";\" "; echo "onmouseover=\"return overlib('" . $overlib . "',"; echo "CAPTION,"; echo "'" . $thisDate . "');\" "; echo "onmouseout=\"return nd();\">". $thisDay ."</a>\n"; } else { echo $thisDay; } } function generateHTML($toUrl) { //configure top navigation $nextMonth = $this->month + 1; $nextYear = $this->year; if($nextMonth == 13) { $nextMonth = 1; $nextYear = $this->year + 1; } $prevMonth = $this->month - 1; $prevYear = $this->year; if($prevMonth == 0) { $prevMonth = 12; $prevYear = $this->year - 1; } //output overlib js path echo "<script type=\"text/javascript\" src=\"" . $this->overlibPath . "\"></script>"; //output overlib div echo "<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>"; //output detail form echo "<form name=\"jump_to_details\" action=\"" . $this->formDetailsAction . "\" "; echo "method=\"POST\">\n"; echo "<input type=\"hidden\" name=\"event\" value=\"\">\n"; echo "</form>"; //output javascript submit form (handler) method echo "<script language=\"Javascript\">\n"; echo "\n"; echo "function goToDetails(thisEvent) {\n"; echo "document.jump_to_details.event.value=thisEvent\n"; echo "document.jump_to_details.submit()\n"; echo "}\n"; echo "</script>\n"; //configure bottom navigation $gobackwards = $toUrl . "&m=" . $prevMonth . "&y=" . $prevYear; $goforward = $toUrl . "&m=" . $nextMonth . "&y=" . $nextYear; echo "<small>"; echo "<table border=\"1\" cellpadding=\"3\">\n"; echo "<tr>\n"; echo " <td colspan=\"7\">"; echo " <table border=\"0\" cellpadding=\"0\" width=\"100%\">\n"; echo " <tr>\n"; echo " <td width=\"5%\"><a href=\"" . $gobackwards . "\"><<</a></td>\n"; echo " <td width=\"90%\" align=\"center\"><b>" . $this->getMonthName($this->month , 1 , $this->year) . " " . $this->year . "</b></td>\n"; echo " <td width=\"5%\"><a href=\"" . $goforward . "\">>></a></td>\n"; echo " </tr>\n"; echo " </table>\n"; echo " </td>"; echo "</tr>\n"; echo "<tr>\n"; echo " <td><b>Sun</b></td>\n"; echo " <td><b>Mon</b></td>\n"; echo " <td><b>Tue</b></td>\n"; echo " <td><b>Wed</b></td>\n"; echo " <td><b>Thur</b></td>\n"; echo " <td><b>Fri</b></td>\n"; echo " <td><b>Sat</b></td>\n"; echo "</tr>\n"; $newrow = 1; $monLoop = $this->getNumDaysOfMonth($this->month, $this->year); $startDay = intval($this->getWeekDay($this->getDayOfMonth( $this->month, 1, $this->year))); $begin = false; for($i=1; $i <= $monLoop; $i++) { if($startDay == 7) { $begin = true; } if($newrow == 8 || $newrow == 1) { echo "<tr>"; $newrow = 1; } if($begin == true) { if( $this->isToday($this->month, $i, $this->year)) { echo " <td><font color=\"red\">"; $this->outputDay(intVal($this->month), intVal($i), intVal($this->year)); echo "</font></td>"; } else { echo " <td>"; $this->outputDay(intVal($this->month), intVal($i), intVal($this->year)); echo "</td>"; } } if($i <= $startDay && $begin == false ) { echo " <td> </td>"; if($i == $startDay) { $begin = true; $i = 0; } } $newrow++; if($newrow == { echo "</tr>"; } } echo "</table>\n"; echo "</small>"; } } ?> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 What's the error message? Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 its a notice and this "Notice: Undefined index: $thisDate in C:\Deskfun\1123 Hooton park website\calendar\myEventsCalendar.php on line 226" Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 224 $thisDate = $thisMonth . "-" . $thisDay . "-" . $thisYear; 226 if($this->eventsId[$thisDate]) { Those are 2 lines I copy and pasted. I assume the array eventsId does NOT have an index at $thisDate. Here's something you can do to debug - after line 224, put this var_dump($thisDate); var_dump($this->eventsId); Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 Ok now im getting this string( "5-1-2009" array(1) { ["5-20-2009"]=> int(2) } Notice: Undefined index: 5-1-2009 in C:\Deskfun\1123 Hooton park website\calendar\myEventsCalendar.php on line 227 absolutly no idea at this lol oh and that dump changes for each day but you can see that if you go on the page Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 Well you know the problem now. Your $thisDate is set to the string "5-1-2009" and your array only has "5-20-2009". Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 Right well im no good at arrays how would i go about fixing this? thanks Quote Link to comment Share on other sites More sharing options...
pcw Posted May 20, 2009 Share Posted May 20, 2009 Could this be used in this script? Here is the link to my topic http://www.phpfreaks.com/forums/index.php/topic,253138.0.html Thanks Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 Im not sure :s i realy do not know what to do with this i dont understand the way in which the $this->eventsId[$thisDate] bit works with teh -> so ive got no hope at figuring out how that output from the var dump is going to help me lol Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 20, 2009 Share Posted May 20, 2009 madspof - read up on PHP OOP. Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 Ok can you point me in the direction of some thing that will help me with my problem and lack of knowledge of array please :-) Quote Link to comment Share on other sites More sharing options...
madspof Posted May 20, 2009 Author Share Posted May 20, 2009 Ive been looking for solutions and cannot find anything can anyone help please? Quote Link to comment Share on other sites More sharing options...
madspof Posted May 21, 2009 Author Share Posted May 21, 2009 can anyone help me with me array as i realy do not know how to fix it and i cannot define it no matter whati try please thanks madsp0f Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.