Hello there
My dad has the following website http://www.guestaccomm.com/index.php which should allow users to register their camping accommodation and place a listing on is site. At the registration page it works fine up unto a point on the form where when the form is submitted the following message then appears:
Parse error: syntax error, unexpected T_FUNCTION in /home/nas02l/g/guestaccomm.com/user/htdocs/lib/calendar.php on line 11
The PHP code for calendar.php is as follows with line 11 being function getMonth($i)
I have tried to find solutions to this but am not very good with PHP as yet. the lad who built this no longer works for my dad.
<?phpphp
/**
* +------------------------------------------------------------------------------+
* Dynamic Calendar Generator
* Author(s): Gobinath
* +------------------------------------------------------------------------------+
* Purpose of the Class: Generate a Calendar Based on Use Input
* File Name : calendar.class.php
*/
function getMonth($i)
{
if ($i==1) return "January";
elseif ($i==2) return "February";
elseif ($i==3) return "March";
elseif ($i==4) return "April";
elseif ($i==5) return "May";
elseif ($i==6) return "June";
elseif ($i==7) return "July";
elseif ($i==8) return "August";
elseif ($i==9) return "September";
elseif ($i==10) return "October";
elseif ($i==11) return "November";
elseif ($i==12) return "December";
else return "January";
}
function daysinmonth($month,$year)
{
$days = 31;
$isLeap = ((($year%4) == 0 && ($year%100)!=0) || ($year%400)==0);
if($month==2)
{
if($isLeap) $days = 29;
else $days = 28;
}
else
{
if($month==9||$month==4||$month==6||$month==11) $days = 30;
}
return $days;
}
class calendar{
// Variable Declaration
var $NOW;
var $curMonth;
var $curYear;
var $curtxtMonth;
var $curDate;
var $curDay;
var $thisMonth;
var $TempMonth;
var $totalDays;
function calendar(){
//Purpose : Constructor of the class and responsible for Variable Initialization
$this->curtxtMonth=array("","January","February","March","April","May","June","July","August","September","October","November","December");
$this->curDay=1;
}
function AssignDate($Month,$Year){
//Purpose : Assign Values to Global variable
$NOW=getdate(); // get the Current server date.
if($Month > 12 || $Month < 1) { $Month = 0; $Year=0;}
if($Month == 0){
$this->curMonth= $NOW["mon"];
}
else{
$this->curMonth= $Month;
}
if($Year == 0){
$this->curYear = $NOW["year"];
}
else{
$this->curYear = $Year;
}
$this->thisMonth=$this->curMonth;
$this->TempMonth=$NOW["month"];
}
function GenerateCalendar($existingvalues,$registered,$max){
$yearRegistered = date("Y",$registered);
$monthRegistered = date("n",$registered);
$allowed = true;
if($yearRegistered==$this->curYear) if($this->curMonth<$monthRegistered) $allowed = false;
if($this->curYear<$yearRegistered) $allowed = false;
//Purpose: Generate the Calendar based on the available Values
$cellCount=0;
$TableCC=0;
?>
<table style="border-collapse:collapse;margin-top:10px;">
<tr>
<th colspan="7" style="background-color:#BAE1FE;border-top:1px solid #0099FF;border-left:1px solid #0099FF;border-right:1px solid #0099FF;"><?php=$this->curtxtMonth[$this->curMonth]." - ".$this->curYear?></th>
</tr>
<tr>
<th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;border-left:1px solid #0099FF;">Sun</th><th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;">Mon</th ><th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;">Tue</th><th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;">Wed</th><th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;">Thu</th><th style="background-color:#BAE1FE;border-bottom:1px solid #0099FF;">Fri</th><th style="background-color:#BAE1FE;border-right:1px solid #0099FF;border-bottom:1px solid #0099FF;">Sat</th>
</tr>
<?phpphp
// Dynamic Calendar Generation Starts Here//
if($TableCC == 0 ) echo "<tr>";
echo " <td>";
while($this->curMonth==$this->thisMonth)
{
$this->thisMonth=date("m",mktime(23,59,59,$this->curMonth,$this->curDay,$this->curYear));
$this->totalDays=date("d",mktime(23,59,59,$this->curMonth,$this->curDay-1,$this->curYear));
$this->curDay++;
}
$firstDayOfMonth = date("w",mktime(0,0,0,$this->curMonth,1,$this->curYear));
if ($firstDayOfMonth > 0) { echo "<tr>"; }
for($cellCount=0;$cellCount<=$firstDayOfMonth-1;$cellCount++) echo "<td></td>";
for ($this->curDay=1;$this->curDay<=$this->totalDays;$this->curDay++)
{
if ($cellCount == 0) { echo "<tr>"; }
if (($this->curDay == $this->curDate) && ($this->TempMonth == $this->curtxtMonth[$this->curMonth])){ ?>
<!-- <td>
<table style="border-collapse:collapse;">
<tr><td><?//$this->curDay?></td></tr>
<tr><td><input type="text" name="" style="width:15px;" /></td></tr>
</table>
</td>-->
<?phpphp } else{ ?>
<td>
<table style="border-collapse:collapse;">
<tr><td><?php=$this->curDay?></td></tr>
<tr><td>
<?phpphp
$tempMonth = (string)$this->curMonth;
$tempDay = (string)$this->curDay;
if(strlen($tempMonth)==1) $tempMonth = "0".$tempMonth;
if(strlen($tempDay)==1) $tempDay = "0".$tempDay;
$inputname = (string)$this->curYear."-".$tempMonth."-".$tempDay;
if(array_key_exists($inputname,$existingvalues)) $inputvalue = $existingvalues[$inputname];
else
{
if(!$allowed) $inputvalue = "";
else $inputvalue = $max;
}
?>
<input <?phpphp if(!$allowed) echo "disabled=\"disabled\" style=\"background-color:#CCCCCC;width:28px;\""; ?> value="<?php=$inputvalue;?>" type="text" name="<?php=$inputname;?>" style="width:28px;" onchange="formchanged();" <?phpphp if($inputvalue=="0") echo "style=\"background-color:#BAE1FE;\"";?><?phpphp if($inputvalue<"0") echo "style=\"background-color:#FF9191;\"";?>/>
</td></tr>
</table>
</td>
<?phpphp }
$cellCount++;
if ($cellCount == 7) { echo "</tr>"; $cellCount=0;}
} // $this->curDay Loop
if ($cellCount > 0 && $cellCount < 7)
{
for ($i=$cellCount; $i<7; $i++) echo "<td>";
echo "</tr>";
}
$TableCC++;
if ($TableCC == 3) { echo "</tr>"; $TableCC = 0; }
echo "</td>";
echo "</table>";
}// GenerateCalendar() Function Ends here.
}
?>
Please help! Its becoming a bit frustrating now!!
Many Thanks
Charlie