corillo181 Posted October 11, 2007 Share Posted October 11, 2007 can anyone see where is this error coming from? Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\wamp\www\untitled.php on line 29 <?php class calendar{ var $year; var $month; var $endDay; function calendar($y,$m){ $this->year = $y; $this->month = $m; $this->startDate=mktime(12,0,0,$this->month,1,$this->year); $this->andDay = date('t',$this->startDate); $this->allTime = getdate($this->startDate); } function displayCells(){ for($count=0;$count < (6*7);$count++){ if(($count%7)==0){ if($this->allTime['mon'] != $this->month){ break; } else { echo '<tr></tr>'; } } } } $cal = new calendar(2007,10); echo '<table border="2"><tr>'; $cal->displayCells(); echo '</tr></table>'; ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted October 11, 2007 Share Posted October 11, 2007 You never closed the brackets to your class. <?php class calendar{ var $year; var $month; var $endDay; function calendar($y,$m) { $this->year = $y; $this->month = $m; $this->startDate=mktime(12,0,0,$this->month,1,$this->year); $this->andDay = date('t',$this->startDate); $this->allTime = getdate($this->startDate); } function displayCells() { for ($count=0; $count < (6*7); $count++) { if (($count%7)==0) { if ($this->allTime['mon'] != $this->month) { break; } else { echo '<tr></tr>'; } } } } } $cal = new calendar(2007,10); echo '<table border="2"><tr>'; $cal->displayCells(); echo '</tr></table>'; ?> Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 11, 2007 Author Share Posted October 11, 2007 whao, and something kept telling me that was the problem, but no matter how closed i looked i couldn't see it. thanx. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted October 11, 2007 Author Share Posted October 11, 2007 additional question. i added some more to the class and it works nicely but how would i find which is the first day of the month..like a Saturday or Tuesday. <?php class calendar{ var $year; var $month; var $endDay; function calendar($y,$m){ $this->year = $y; $this->month = $m; $this->startDate=mktime(12,0,0,$this->month,1,$this->year); $this->andDay = date('t',$this->startDate); $this->allTime = getdate($this->startDate); } function displayCells(){ $days = array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); //takes each day of the array and makes it in to the head days foreach($days as $day){ echo"<td align=\"center\">$day</td>"; } for($count=0;$count < (6*7);$count++){ $dayArray=getdate($start); if(($count%7)==0){ if($this->allTime['mon'] != $this->month){ break; } else { echo '<tr></tr>'; } } if($count < $this->andDay){ echo "\t<td>$count</td>\n"; } else { echo '<td>blank</td>'; $start +=(60*60*24); } } } } $cal = new calendar(2007,10); echo '<table border="2"><tr>'; $cal->displayCells(); echo '</tr></table>'; ?> 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.