| | |
php-calendar
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 58
Reputation:
Solved Threads: 0
hi
i design a php event calendar
but it showing some error, anyone check it plz..
Parse error: syntax error, unexpected T_ELSE in W:\www\Calendar-php\admin\calAdd.php on line 149
i design a php event calendar
but it showing some error, anyone check it plz..
Parse error: syntax error, unexpected T_ELSE in W:\www\Calendar-php\admin\calAdd.php on line 149
php Syntax (Toggle Plain Text)
<html> <head> <title>Calendar: Add</title> <META HTTP-EQUIV="refresh" content="1;URL=../calendar.php"> <LINK rel="stylesheet" type="text/css" name="style" href="../calendar.css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php //returns highest key in the database function getMaxKey($db) { $maxKey = 0; $sortby = "event_key"; $result = $db->getall(); foreach($result as $item){ $key = $item["event_key"]; if($key > $maxKey) $maxKey = $key; } return $maxKey; } // Include the FFDB library include("../ffdb.inc.php"); //open db or create new db $db = new FFDB(); if (!$db->open("../calendar")) { // Define the database shema. // Note that the "last_name" field is our key. $schema = array( array("event_key", FFDB_INT, "key"), array("event_name", FFDB_STRING), array("event_description", FFDB_STRING), array("event_submitted_by", FFDB_STRING), array("event_month", FFDB_STRING), array("event_day", FFDB_INT), array("event_year", FFDB_INT) ); // Try and create it... if (!$db->create("calendar", $schema)) { echo "Error creating database\n"; return; } } //if no key file create a new one if(!file_exists("key.dat")) { $newKey = getMaxKey($db); $newFile = fopen("key.dat", "w") Or die("Can't open file"); fwrite($newFile,$newKey); fclose($newFile); } //add a record //convert forms to record $fileread = fopen("key.dat", "r")Or die("Can't open file"); $data = (int) fread($fileread, 10); fclose($fileread); $data++; $fileread = fopen("key.dat", "w") Or die("Can't open file"); fwrite($fileread,$data); fclose($fileread); //removes escape slashes $event = stripslashes($event); $description = stripslashes($description); $submitted = stripslashes($submitted); //add html entities $event = htmlentities($event,ENT_QUOTES); $submitted = htmlentities($submitted,ENT_QUOTES); $record["event_key"] = $data; $record["event_name"] = $event; $record["event_description"] = $description; $record["event_submitted_by"] = $submitted; $record["event_month"] = $month; list($record["event_day"]) = sscanf($day, "%d"); // string -> int list($record["event_year"]) = sscanf($year, "%d"); // string -> int // Add a _new_ entry echo(""); if (!$db->add($record)) echo("failed!\n"); else { //table to display after adding $addedTable =" <center><font class=\"back\">Record Added: taking you back</font> </center> <table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" bgcolor=\"#000000\" align=\"center\"><tr><td> <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CC0000\" align=\"center\"> <tr><td><font class=\"addHead\"><a href=\"calendar.php\" class=\"addHead\">Calendar</a></font></TD></tr> <tr><td> <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CCCCCC\"> <tr> <td width=\"150\" align=\"right\" height=\"26\"><font class=\"AddLeft\">Event : </font></td> <td width=\"350\" height=\"26\"><font class=\"AddRight\">$event</font></td> </tr> <tr bgcolor=\"#E3E3E3\"> <td width=\"150\" align=\"right\"><font class=\"AddLeft\">Event Description : </font></td> <td width=\"350\"><font class=\"AddRight\">$description</font></td> </tr> <tr> <td width=\"150</h5>\" align=\"right\"><font class=\"AddLeft\">Date : </font></td> <td width=\"350\" ><font class=\"AddRight\">$day $month $year</font></td> </tr> <tr bgcolor=\"#E3E3E3\"> <td width=\"150\" align=\"right\"><font class=\"AddLeft\">Submitted By : </font></td> <td width=\"350\"><font class=\"AddRight\">$submitted</font></td> </tr> </table> </td><tr> <tr><td align=\"right\"></td></tr> </table> </td></tr></table> "; echo $addedTable; } else { echo ("go back and add event"); ?> </body> </html>
Last edited by peter_budo; Mar 6th, 2009 at 10:38 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Feb 2009
Posts: 83
Reputation:
Solved Threads: 7
•
•
•
•
hi
i design a php event calendar
but it showing some error, anyone check it plz..
Parse error: syntax error, unexpected T_ELSE in W:\www\Calendar-php\admin\calAdd.php on line 149
<html>
<head>
<title>Calendar: Add</title>
<META HTTP-EQUIV="refresh" content="1;URL=../calendar.php">
<LINK rel="stylesheet" type="text/css" name="style" href="../calendar.css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
//returns highest key in the database
function getMaxKey($db) {
$maxKey = 0;
$sortby = "event_key";
$result = $db->getall();
foreach($result as $item){
$key = $item["event_key"];
if($key > $maxKey)
$maxKey = $key;
}
return $maxKey;
}
// Include the FFDB library
include("../ffdb.inc.php");
//open db or create new db
$db = new FFDB();
if (!$db->open("../calendar"))
{
// Define the database shema.
// Note that the "last_name" field is our key.
$schema = array(
array("event_key", FFDB_INT, "key"),
array("event_name", FFDB_STRING),
array("event_description", FFDB_STRING),
array("event_submitted_by", FFDB_STRING),
array("event_month", FFDB_STRING),
array("event_day", FFDB_INT),
array("event_year", FFDB_INT)
);
// Try and create it...
if (!$db->create("calendar", $schema))
{
echo "Error creating database\n";
return;
}
}
//if no key file create a new one
if(!file_exists("key.dat"))
{
$newKey = getMaxKey($db);
$newFile = fopen("key.dat", "w") Or die("Can't open file");
fwrite($newFile,$newKey);
fclose($newFile);
}
//add a record
//convert forms to record
$fileread = fopen("key.dat", "r")Or die("Can't open file");
$data = (int) fread($fileread, 10);
fclose($fileread);
$data++;
$fileread = fopen("key.dat", "w") Or die("Can't open file");
fwrite($fileread,$data);
fclose($fileread);
//removes escape slashes
$event = stripslashes($event);
$description = stripslashes($description);
$submitted = stripslashes($submitted);
//add html entities
$event = htmlentities($event,ENT_QUOTES);
$submitted = htmlentities($submitted,ENT_QUOTES);
$record["event_key"] = $data;
$record["event_name"] = $event;
$record["event_description"] = $description;
$record["event_submitted_by"] = $submitted;
$record["event_month"] = $month;
list($record["event_day"]) = sscanf($day, "%d"); // string -> int
list($record["event_year"]) = sscanf($year, "%d"); // string -> int
// Add a _new_ entry
echo("");
if (!$db->add($record))
echo("failed!\n");
else {
//table to display after adding
$addedTable ="
<center><font class=\"back\">Record Added: taking you back</font> </center>
<table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" bgcolor=\"#000000\" align=\"center\"><tr><td>
<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CC0000\" align=\"center\">
<tr><td><font class=\"addHead\"><a href=\"calendar.php\" class=\"addHead\">Calendar</a></font></TD></tr>
<tr><td>
<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CCCCCC\">
<tr>
<td width=\"150\" align=\"right\" height=\"26\"><font class=\"AddLeft\">Event : </font></td>
<td width=\"350\" height=\"26\"><font class=\"AddRight\">$event</font></td>
</tr>
<tr bgcolor=\"#E3E3E3\">
<td width=\"150\" align=\"right\"><font class=\"AddLeft\">Event Description : </font></td>
<td width=\"350\"><font class=\"AddRight\">$description</font></td>
</tr>
<tr>
<td width=\"150</h5>\" align=\"right\"><font class=\"AddLeft\">Date : </font></td>
<td width=\"350\" ><font class=\"AddRight\">$day $month $year</font></td>
</tr>
<tr bgcolor=\"#E3E3E3\">
<td width=\"150\" align=\"right\"><font class=\"AddLeft\">Submitted By : </font></td>
<td width=\"350\"><font class=\"AddRight\">$submitted</font></td>
</tr>
</table>
</td><tr>
<tr><td align=\"right\"></td></tr>
</table>
</td></tr></table>
";
echo $addedTable;
}
else
{
echo ("go back and add event");
?>
</body>
</html>
Hi rohini..
plz put ur code in CODE tags(#)
ok..
at last line u have to close else part }
i think you are using two else loops here ..
one is on line : 103
and another one is on line 149.
And you just forget to close your second else loop..
You loop structure is not good...
Concentrate on those...
And use code tags by next time....
one is on line : 103
and another one is on line 149.
And you just forget to close your second else loop..
You loop structure is not good...
Concentrate on those...
And use code tags by next time....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
•
•
Join Date: Feb 2009
Posts: 58
Reputation:
Solved Threads: 0
Notice: Undefined variable: sent_month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\calendar.php on line 431
php Syntax (Toggle Plain Text)
<html> <head> <title>Calendar</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <LINK rel="stylesheet" type="text/css" name="style" href="calendar.css"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table cellpadding="0" cellspacing="2" border="0" align="center" bgcolor="#000000"><tr><td> <table cellpadding="2" cellspacing="0" border="0" align="center" bgcolor="#CC0000"> <tr><td width="200" valign="middle">  </td> <td width="348" align="center"> </td> <td width="200" align="right"><A HREF="admin/add.php" class="addEvent">Add Event </a></td> </tr> </table> </td></tr></table><BR><BR> <?php // Include the FFDB library include("ffdb.inc.php"); //open db or create new db $db = new FFDB(); if (!$db->open("calendar")) { // Define the database shema. // Note that the "last_name" field is our key. $schema = array( array("event_key", FFDB_INT, "key"), array("event_name", FFDB_STRING), array("event_description", FFDB_STRING), array("event_submitted_by", FFDB_STRING), array("event_month", FFDB_STRING), array("event_day", FFDB_INT), array("event_year", FFDB_INT) ); // Try and create it... if (!$db->create("calendar", $schema)) { echo "Error creating database\n"; return; } } function today($record) { global $event_day; global $event_month; global $event_year; //echo "$event_month $event_day $event_year"; if (($record["event_month"] == $event_month) && ($record["event_day"] == $event_day) && ($record["event_year"] == $event_year)) return true; return false; } function show_event($record){ $eventNumber = $record["event_key"]; $eventName = $record["event_name"]; echo "<font class=\"eventLink\">-<a href=\"viewEvent.php?eventNumber=$eventNumber\" class=\"eventLink\">$eventName</a></font> <br>"; } function getEvents(){ global $db; //get events for today $result = $db->getbyfunction("today"); //display events if there are any if($result != null) foreach($result as $item) show_event($item); } function days_in_month($_month, $_year) { if($_month == 2) { return days_in_feb($_year); } else { if($_month == 1 || $_month == 3 || $_month == 5 || $_month == 7 || $_month == 8 || $_month == 10 || $_month == 12) { return(31); } else { return(30); } } } function selectMonth($_month){ $selectstart = " <select name=\"sent_month\"> "; $selectend = " </select>"; echo $selectstart; echo "<option value=\"January\""; if($_month == 1) echo " selected=\"selected\" "; echo ">January</option> "; echo "<option value=\"February\""; if($_month == 2) echo " selected=\"selected\" "; echo ">February</option> "; echo "<option value=\"March\""; if($_month == 3) echo " selected=\"selected\" "; echo ">March</option> "; echo "<option value=\"April\""; if($_month == 4) echo " selected=\"selected\" "; echo ">April</option> "; echo "<option value=\"May\""; if($_month == 5) echo " selected=\"selected\" "; echo ">May</option> "; echo "<option value=\"June\""; if($_month == 6) echo " selected=\"selected\" "; echo ">June</option> "; echo "<option value=\"July\""; if($_month == 7) echo " selected=\"selected\" "; echo ">July</option> "; echo "<option value=\"August\""; if($_month == 8) echo " selected=\"selected\" "; echo ">August</option> "; echo "<option value=\"September\""; if($_month == 9) echo " selected=\"selected\" "; echo ">September</option> "; echo "<option value=\"October\""; if($_month == 10) echo " selected=\"selected\" "; echo ">October</option> "; echo "<option value=\"November\""; if($_month == 11) echo " selected=\"selected\" "; echo ">November</option> "; echo "<option value=\"December\""; if($_month == 12) echo " selected=\"selected\" "; echo ">December</option> "; echo $selectend; } function selectYear($selectedyear){ $day = getdate(); $year = $day['year']; $selectyeartop = " <select name=\"sent_year\"> "; $selectyearbottom = " </select> "; echo $selectyeartop; for($i=$year; $i<$year+5; $i++) { echo "<option value=\"$i\""; if($i == $selectedyear) echo "selected=\"selected\""; echo "> $i</option> "; } echo $selectyearbottom; } function convertMonth($alpha_month){ if($alpha_month == "January") return 1; else if($alpha_month== "February") return 2; else if($alpha_month== "February") return 2; else if($alpha_month== "March") return 3; else if($alpha_month== "April") return 4; else if($alpha_month== "May") return 5; else if($alpha_month== "June") return 6; else if($alpha_month== "July") return 7; else if($alpha_month== "August") return 8; else if($alpha_month== "September") return 9; else if($alpha_month== "October") return 10; else if($alpha_month== "November") return 11; else if($alpha_month== "December") return 12; return 1; } function days_in_feb($year){ //$year must be YYYY //[gregorian] leap year math : if ($year < 0) $year++; $year += 4800; if ( ($year % 4) == 0) { if (($year % 100) == 0) { if (($year % 400) == 0) { return(29); } else { return(28); } } else { return(29); } } else { return(28); } } /* prints the month and year that are passed to it in $date */ function printMonth($_month, $_year) { $timestamp = mktime(0,0,0,$_month,1,2000); $date = getdate ($timestamp); $monthText = $date['month']; $monthtext1 = " <!-- month heading --------------------------------------------> <table align=\"center\"> <tr> <td align=\"left\"> <form name=\"goto\" action=\"calendar.php\" method=\"POST\"> <table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" bgcolor=\"#000000\" align=\"center\"> <tr><td> <table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CC0000\"> <tr><td width=\"200\">"; $monthtext2 = "<input type=\"image\" src=\"go.gif\" name=\"go\" border=\"0\"> </td></tr></table> </td></tr></table> </form> </td> <td align=\"center\" width=\"355\" valign=\"top\"><font class=\"month\">$monthText $_year</font></td> <td align=\"right\" width=\"186\" valign=\"top\"></td> </tr> </table> <!-- end of month heading -------------------------------------> "; echo "$monthtext1"; selectMonth($_month); selectYear($_year); echo "$monthtext2"; } /* prints the bar that contains the days of the week */ function printDays() { $daybar = " <!-- days of the week heading ---------------------------------> <table align=\"center\" bgcolor=\"#000000\"> <TR> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Sunday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Monday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Tuesday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Wednesday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Thursday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Friday</font></td> <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Saturday</font></td> </tr> <!-- end days of the week heading -----------------------------> "; echo $daybar; } /* opens table for calendar which is closed by last week, then prints the first week to the calendar */ function printFirstWeek($_day) { global $event_day; //write table declarations echo " <!-- begin day boxes ------------------------------------------> <tr> "; $current_day = 1; $spot = 0; while ($spot < $_day){ echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#e3e3e3\"> </td> "; $spot++; } while ($spot < 7){ $event_day = $current_day; echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$current_day</font><br>"; getEvents(); echo "</td> "; $spot++; $current_day++; } echo"</tr> "; return $current_day; } function printWeek($_day, $_last) { global $event_day; while ($_day <= ($_last - 7)){ $count = 0; echo "<TR> "; while($count < 7){ $event_day = $_day; echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$_day</font><br>"; getEvents(); echo "</td> "; $_day++; $count++; } echo "</TR> "; } return $_day; } function printLastWeek($_day, $_lastday) { global $event_day; $count = 0; echo "<TR> "; while($count <= $_lastday) { $event_day = $_day; echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$_day</font><br>"; getEvents(); echo "</td> "; $_day++; $count++; } while($count < 7) { echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#e3e3e3\"> </td> "; $count++; $_day++; } echo "</tr> "; echo "</table> <!-- end day boxes ------------------------------------------> "; } //calculate all date information needed if($sent_month && $sent_year){ $month = convertMonth($sent_month); $year = $sent_year; $event_day = 1; $event_month = $sent_month; $event_year = $year; } else { $day = getdate(); $month = $month = $day['mon']; $mday = $mday = $day['mday']; $year = $year = $day['year']; $event_day = 1; $event_month = $day['month']; $event_year = $year; } $days_in_month = days_in_month ($month, $year); $first_day = mktime(0,0,0,$month,1,$year); $date_first = getdate ($first_day); $last_day = mktime(0,0,0,$month,$days_in_month,$year); $date_last = getdate($last_day); $dayofweekfirst = $date_first['wday']; $dayofweeklast = $date_last['wday']; //end date calculations printMonth($month, $year); printDays(); $current = printFirstWeek($dayofweekfirst); $current = printWeek($current, $days_in_month); printLastWeek($current, $dayofweeklast); ?> <table cellpadding="0" cellspacing="0" border="0" align="center"><TR><TD width="750"><A href="viewAll.php" class="viewEvent">View All Events</a></td></tr></table> <table cellpadding="0" cellspacing="0" border="0" align="center"> <tr> <td width="600" align="center"> </td> </tr> </table> </BODY> </HTML>
Last edited by peter_budo; Mar 6th, 2009 at 10:39 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Feb 2009
Posts: 58
Reputation:
Solved Threads: 0
Notice: Undefined variable: event in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 46
Notice: Undefined variable: description in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 47
Notice: Undefined variable: submitted in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 48
Notice: Undefined variable: month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 55
Notice: Undefined variable: day in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 56
Notice: Undefined variable: year in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 57
Fatal error: Invalid string value field during add: event_month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\ffdb.inc.php on line 487
Notice: Undefined variable: description in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 47
Notice: Undefined variable: submitted in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 48
Notice: Undefined variable: month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 55
Notice: Undefined variable: day in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 56
Notice: Undefined variable: year in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\admin\calAdd.php on line 57
Fatal error: Invalid string value field during add: event_month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\ffdb.inc.php on line 487
Last edited by peter_budo; Mar 6th, 2009 at 10:44 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags. Code moved into attached file. DO NOT POST SUCH LONG CODE!
•
•
Join Date: Feb 2009
Posts: 58
Reputation:
Solved Threads: 0
hii
i m designing a php event based calendar
this is my code, can anyone tell me its script code,mine is not working..
Parse error: syntax error, unexpected '<' in W:\www\ccc\cal.php on line 34
i m designing a php event based calendar
this is my code, can anyone tell me its script code,mine is not working..
php Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php // Get values from query string $day = $_GET["day"]; $month = $_GET["month"]; $year = $_GET["year"]; $sel = $_GET["sel"]; $what = $_GET["what"]; if($day == "") $day = date("j"); if($month == "") $month = date("m"); if($year == "") $year = date("Y"); $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; $numEventsThisMonth = 0; $hasEvent = false; $todaysEvents = ""; <table width='350' border='0' cellspacing='0' cellpadding='0'> <tr> <td class='head' width='50'>S</td> <td class='head' width='50'>M</td> <td class='head' width='50'>T</td> <td class='head' width='50'>W</td> <td class='head' width='50'>T</td> <td class='head' width='50'>F</td> <td class='head' width='50'>S</td> </tr> $numDays = date("t", $currentTimeStamp); for($i = 1; $i < $numDays+1; $i++, $counter++) { $timeStamp = strtotime("$year-$month-$i"); if($i == 1) { // Workout when the first day of the month is $firstDay = date("w", $timeStamp); for($j = 0; $j < $firstDay; $j++, $counter++) echo "<td> </td>"; } if($counter % 7 == 0) echo "</tr><tr>"; echo "<td width='50'>$I</td>"; if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6) echo "class='weekend'"; else if($i == date("d") && $month == date("m") && $year == date("Y")) echo "class='today'"; else echo "class='normal'"; $monthName = date("F", $currentTimeStamp); <tr> <td width='50' colspan='1'> <input type='button' value=' < ' onClick='goLastMonth(<?php echo $month . ", " . $year; ?>)'> </td> <td width='250' colspan='5'> <span class='title'><?php echo $monthName . " " . $year; ?></span><br> </td> <td width='50' colspan='1' align='right'> <input type='button' value=' > ' onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)'> </td> </tr> <script> function goLastMonth(month, year) { // If the month is Januaru, decrement the year if(month == 1) { --year; month = 13; } document.location.href = 'cal.php?month='+(month-1)+'&year='+year; } cal.php?month=12&year=2002 function goNextMonth(month, year) { // If the month is December, increment the year if(month == 12) { ++year; month = 0; } document.location.href = 'cal.php?month='+(month+1)+'&year='+year; } </script> <?php function ReadEvents($Month) function ReadEvents($Month) { $theEvents = array(); $eventCounter = 0; // Make sure that the file exists if(!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE)) { $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "w") or die("<span class='error'>ERROR: Couldn't create events file.</span>"); @fclose($fp); } $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb") or die("<span class='error'>ERROR: Couldn't open events file to read events.</span>"); define("EVENT_FILE", "cal_events.text"); while($data = fread($fp, 1024)) { $events .= $data; } @fclose($fp); // Seperate the data into line-seperated arrays $arrEvents = explode("\r\n", $events); // Loop through the results and pick the arrays // that match the selected month for($i = 0; $i < sizeof($arrEvents); $i+=3) { // Get each part of the events date as an index // of an array $arrEventDate = explode(" ", $arrEvents[$i]); // If the month is the selected month the grab // the details of this event if((int)$arrEventDate[0] == (int)$Month) { $theEvents[$eventCounter++] = array("day" => $arrEventDate[1], "name" => $arrEvents[$i+1], "desc" => $arrEvents[$i+2]); } } return $theEvents; foreach($arrEvents as $eventEntry) { if($eventEntry["day"] == $i) { // We have at least one event for the day $hasEvent = true; $numEventsThisMonth++; … } } } // Is it a weekend, does it have events, etc if($i == $day && $month == date("m") && $year == date("Y") && $sel == 1) echo "class='selected'"; else if($i == $day && $sel == 1) echo "class='selected'"; else if($hasEvent == true) echo "class='event'"; else if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6) echo "class='weekend'"; else if($i == date("d") && $month == date("m") && $year == date("Y")) echo "class='today'"; else echo "class='normal'"; $arrEvents = ReadEvents($month); ... foreach($arrEvents as $eventEntry) { if($eventEntry["day"] == $i) { // We have at least one event for the day $hasEvent = true; $numEventsThisMonth++; if($eventEntry["day"] == $day) { // Add the event to the $todaysEvents variable $todaysEvents .= "<span class='eventTitle'>" . stripslashes($eventEntry["name"]) . "</span>"; $todaysEvents .= "<span class='eventDesc'><br>" . stripslashes($eventEntry["desc"]) . "</span><br>"; $todaysEvents .= " <a href='cal.php?sel=1&what=delPost&day=$day&month=$month&year=$year&eName=" . urlencode($eventEntry["name"]) . "&eDesc=" . urlencode($eventEntry["desc"]) . "'>[Remove]</a><br><br>"; } } } if($sel == 1) { echo "<tr>"; echo " <td width='350' colspan='7'>"; echo " <hr size='1' color='#CACACA' noshade>"; echo " <span class='Title'>Today's Events</span><br><br>"; echo $todaysEvents; echo " </td>"; echo "</tr>"; } ?> </body> </html>
Parse error: syntax error, unexpected '<' in W:\www\ccc\cal.php on line 34
Last edited by peter_budo; Mar 6th, 2009 at 10:46 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
•
•
hii
i m designing a php event based calendar
this is my code, can anyone tell me its script code,mine is not working..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
// Get values from query string
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];
$sel = $_GET["sel"];
$what = $_GET["what"];
if($day == "")
$day = date("j");
if($month == "")
$month = date("m");
if($year == "")
$year = date("Y");
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F", $currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
$numEventsThisMonth = 0;
$hasEvent = false;
$todaysEvents = "";
<table width='350' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td class='head' width='50'>S</td>
<td class='head' width='50'>M</td>
<td class='head' width='50'>T</td>
<td class='head' width='50'>W</td>
<td class='head' width='50'>T</td>
<td class='head' width='50'>F</td>
<td class='head' width='50'>S</td>
</tr>
$numDays = date("t", $currentTimeStamp);
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++)
echo "<td> </td>";
}
if($counter % 7 == 0)
echo "</tr><tr>";
echo "<td width='50'>$I</td>";
if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
echo "class='weekend'";
else
if($i == date("d") && $month == date("m") && $year == date("Y"))
echo "class='today'";
else
echo "class='normal'";
$monthName = date("F", $currentTimeStamp);
<tr>
<td width='50' colspan='1'>
<input type='button' value=' < ' onClick='goLastMonth(<?php echo $month . ", " . $year; ?>)'>
</td>
<td width='250' colspan='5'>
<span class='title'><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width='50' colspan='1' align='right'>
<input type='button' value=' > ' onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)'>
</td>
</tr>
<script>
function goLastMonth(month, year)
{
// If the month is Januaru, decrement the year
if(month == 1)
{
--year;
month = 13;
}
document.location.href = 'cal.php?month='+(month-1)+'&year='+year;
}
cal.php?month=12&year=2002
function goNextMonth(month, year)
{
// If the month is December, increment the year
if(month == 12)
{
++year;
month = 0;
}
document.location.href = 'cal.php?month='+(month+1)+'&year='+year;
}
</script>
<?php
function ReadEvents($Month)
function ReadEvents($Month)
{
$theEvents = array();
$eventCounter = 0;
// Make sure that the file exists
if(!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE))
{
$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "w")
or die("<span class='error'>ERROR: Couldn't create events file.</span>");
@fclose($fp);
}
$fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb")
or die("<span class='error'>ERROR: Couldn't open events file to read events.</span>");
define("EVENT_FILE", "cal_events.text");
while($data = fread($fp, 1024))
{
$events .= $data;
}
@fclose($fp);
// Seperate the data into line-seperated arrays
$arrEvents = explode("\r\n", $events);
// Loop through the results and pick the arrays
// that match the selected month
for($i = 0; $i < sizeof($arrEvents); $i+=3)
{
// Get each part of the events date as an index
// of an array
$arrEventDate = explode(" ", $arrEvents[$i]);
// If the month is the selected month the grab
// the details of this event
if((int)$arrEventDate[0] == (int)$Month)
{
$theEvents[$eventCounter++] = array("day" => $arrEventDate[1], "name" => $arrEvents[$i+1], "desc" => $arrEvents[$i+2]);
}
}
return $theEvents;
foreach($arrEvents as $eventEntry)
{
if($eventEntry["day"] == $i)
{
// We have at least one event for the day
$hasEvent = true;
$numEventsThisMonth++;
…
}
}
}
// Is it a weekend, does it have events, etc
if($i == $day && $month == date("m") && $year == date("Y") && $sel == 1)
echo "class='selected'";
else if($i == $day && $sel == 1)
echo "class='selected'";
else if($hasEvent == true)
echo "class='event'";
else
if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
echo "class='weekend'";
else
if($i == date("d") && $month == date("m") && $year == date("Y"))
echo "class='today'";
else
echo "class='normal'";
$arrEvents = ReadEvents($month);
...
foreach($arrEvents as $eventEntry)
{
if($eventEntry["day"] == $i)
{
// We have at least one event for the day
$hasEvent = true;
$numEventsThisMonth++;
if($eventEntry["day"] == $day)
{
// Add the event to the $todaysEvents variable
$todaysEvents .= "<span class='eventTitle'>" . stripslashes($eventEntry["name"]) . "</span>";
$todaysEvents .= "<span class='eventDesc'><br>" . stripslashes($eventEntry["desc"]) . "</span><br>";
$todaysEvents .= " <a href='cal.php?sel=1&what=delPost&day=$day&month=$month&year=$year&eName=" . urlencode($eventEntry["name"]) . "&eDesc=" . urlencode($eventEntry["desc"]) . "'>[Remove]</a><br><br>";
}
}
}
if($sel == 1)
{
echo "<tr>";
echo " <td width='350' colspan='7'>";
echo " <hr size='1' color='#CACACA' noshade>";
echo " <span class='Title'>Today's Events</span><br><br>";
echo $todaysEvents;
echo " </td>";
echo "</tr>";
}
?>
</body>
</html>
Parse error: syntax error, unexpected '<' in W:\www\ccc\cal.php on line 34
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Similar Threads
- Display Events in Calendar (HTML and CSS)
- free PHP script to add calendar (PHP)
- PHP calendar help please :) (PHP)
- calendar!!! (PHP)
- Anyone work with a wicked cool PHP Calendar before (PHP)
- Zend PHP Certification (PHP)
- IE is hijacked by http://th.msie.cc/index.php?aid=20035 (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Hello, someone please HELP me
- Next Thread: xpath Invalid expression
| Thread Tools | Search this Thread |
# 5.2.10 ajax apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date display dissertation dynamic echo echo$_get[x]changingitintovariable... email error file files folder form forms function functions google href htaccess html image images include insert integration ip java javascript joomla ldap legislation limit link local login loop mail memberships menu mlm multiple multipletables mysql mysqlquery oop open paypal pdf persist php problem query radio random recursion regex remote rss script search server sessions sms soap sockets source space spam sql syntax system table tutorial update upload url validator variable video web xml youtube






