php-calendar

Reply

Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

php-calendar

 
0
  #1
Mar 5th, 2009
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

  1. <html>
  2. <head>
  3. <title>Calendar: Add</title>
  4.  
  5.  
  6. <META HTTP-EQUIV="refresh" content="1;URL=../calendar.php">
  7. <LINK rel="stylesheet" type="text/css" name="style" href="../calendar.css">
  8. </head>
  9.  
  10. <body bgcolor="#FFFFFF" text="#000000">
  11.  
  12.  
  13.  
  14. <?php
  15.  
  16.  
  17. //returns highest key in the database
  18. function getMaxKey($db) {
  19.  
  20. $maxKey = 0;
  21.  
  22. $sortby = "event_key";
  23. $result = $db->getall();
  24.  
  25. foreach($result as $item){
  26. $key = $item["event_key"];
  27. if($key > $maxKey)
  28. $maxKey = $key;
  29. }
  30.  
  31. return $maxKey;
  32.  
  33. }
  34.  
  35. // Include the FFDB library
  36. include("../ffdb.inc.php");
  37.  
  38. //open db or create new db
  39. $db = new FFDB();
  40. if (!$db->open("../calendar"))
  41. {
  42. // Define the database shema.
  43. // Note that the "last_name" field is our key.
  44. $schema = array(
  45. array("event_key", FFDB_INT, "key"),
  46. array("event_name", FFDB_STRING),
  47. array("event_description", FFDB_STRING),
  48. array("event_submitted_by", FFDB_STRING),
  49. array("event_month", FFDB_STRING),
  50. array("event_day", FFDB_INT),
  51. array("event_year", FFDB_INT)
  52. );
  53.  
  54. // Try and create it...
  55. if (!$db->create("calendar", $schema))
  56. {
  57. echo "Error creating database\n";
  58. return;
  59. }
  60. }
  61.  
  62. //if no key file create a new one
  63. if(!file_exists("key.dat"))
  64. {
  65. $newKey = getMaxKey($db);
  66. $newFile = fopen("key.dat", "w") Or die("Can't open file");
  67. fwrite($newFile,$newKey);
  68. fclose($newFile);
  69.  
  70. }
  71.  
  72. //add a record
  73. //convert forms to record
  74. $fileread = fopen("key.dat", "r")Or die("Can't open file");
  75. $data = (int) fread($fileread, 10);
  76. fclose($fileread);
  77. $data++;
  78. $fileread = fopen("key.dat", "w") Or die("Can't open file");
  79. fwrite($fileread,$data);
  80. fclose($fileread);
  81.  
  82. //removes escape slashes
  83. $event = stripslashes($event);
  84. $description = stripslashes($description);
  85. $submitted = stripslashes($submitted);
  86.  
  87. //add html entities
  88. $event = htmlentities($event,ENT_QUOTES);
  89. $submitted = htmlentities($submitted,ENT_QUOTES);
  90.  
  91. $record["event_key"] = $data;
  92. $record["event_name"] = $event;
  93. $record["event_description"] = $description;
  94. $record["event_submitted_by"] = $submitted;
  95. $record["event_month"] = $month;
  96. list($record["event_day"]) = sscanf($day, "%d"); // string -> int
  97. list($record["event_year"]) = sscanf($year, "%d"); // string -> int
  98.  
  99. // Add a _new_ entry
  100. echo("");
  101. if (!$db->add($record))
  102. echo("failed!\n");
  103. else {
  104.  
  105.  
  106.  
  107. //table to display after adding
  108. $addedTable ="
  109.  
  110.  
  111. <center><font class=\"back\">Record Added: taking you back</font> </center>
  112. <table cellpadding=\"0\" cellspacing=\"2\" border=\"0\" bgcolor=\"#000000\" align=\"center\"><tr><td>
  113. <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CC0000\" align=\"center\">
  114. <tr><td><font class=\"addHead\"><a href=\"calendar.php\" class=\"addHead\">Calendar</a></font></TD></tr>
  115. <tr><td>
  116.  
  117. <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CCCCCC\">
  118.  
  119. <tr>
  120. <td width=\"150\" align=\"right\" height=\"26\"><font class=\"AddLeft\">Event : </font></td>
  121. <td width=\"350\" height=\"26\"><font class=\"AddRight\">$event</font></td>
  122. </tr>
  123.  
  124. <tr bgcolor=\"#E3E3E3\">
  125. <td width=\"150\" align=\"right\"><font class=\"AddLeft\">Event Description : </font></td>
  126. <td width=\"350\"><font class=\"AddRight\">$description</font></td>
  127. </tr>
  128.  
  129. <tr>
  130. <td width=\"150</h5>\" align=\"right\"><font class=\"AddLeft\">Date : </font></td>
  131. <td width=\"350\" ><font class=\"AddRight\">$day $month $year</font></td>
  132. </tr>
  133.  
  134. <tr bgcolor=\"#E3E3E3\">
  135. <td width=\"150\" align=\"right\"><font class=\"AddLeft\">Submitted By : </font></td>
  136. <td width=\"350\"><font class=\"AddRight\">$submitted</font></td>
  137. </tr>
  138. </table>
  139. </td><tr>
  140. <tr><td align=\"right\"></td></tr>
  141. </table>
  142. </td></tr></table>
  143.  
  144. ";
  145.  
  146. echo $addedTable;
  147. }
  148.  
  149. else
  150. {
  151. echo ("go back and add event");
  152. ?>
  153. </body>
  154. </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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 83
Reputation: ahmksssv is an unknown quantity at this point 
Solved Threads: 7
ahmksssv ahmksssv is offline Offline
Junior Poster in Training

Re: php-calendar

 
0
  #2
Mar 5th, 2009
Originally Posted by rohnni View Post
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 }
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: php-calendar

 
0
  #3
Mar 5th, 2009
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....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

Re: php-calendar

 
0
  #4
Mar 5th, 2009
yup :-)) thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

Re: php-calendar

 
0
  #5
Mar 5th, 2009
Notice: Undefined variable: sent_month in E:\domains\h\highweb.co.uk\user\htdocs\geeta\assignments\php\Calendar-php\calendar.php on line 431


  1. <html>
  2. <head>
  3. <title>Calendar</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <LINK rel="stylesheet" type="text/css" name="style" href="calendar.css">
  6. </head>
  7.  
  8. <body bgcolor="#FFFFFF" text="#000000">
  9.  
  10. <table cellpadding="0" cellspacing="2" border="0" align="center" bgcolor="#000000"><tr><td>
  11. <table cellpadding="2" cellspacing="0" border="0" align="center" bgcolor="#CC0000">
  12. <tr><td width="200" valign="middle">&nbsp;&nbsp</td>
  13. <td width="348" align="center">&nbsp;</td>
  14. <td width="200" align="right"><A HREF="admin/add.php" class="addEvent">Add Event&nbsp;&nbsp; </a></td>
  15. </tr>
  16. </table>
  17. </td></tr></table><BR><BR>
  18.  
  19.  
  20. <?php
  21. // Include the FFDB library
  22. include("ffdb.inc.php");
  23.  
  24. //open db or create new db
  25. $db = new FFDB();
  26. if (!$db->open("calendar"))
  27. {
  28. // Define the database shema.
  29. // Note that the "last_name" field is our key.
  30. $schema = array(
  31. array("event_key", FFDB_INT, "key"),
  32. array("event_name", FFDB_STRING),
  33. array("event_description", FFDB_STRING),
  34. array("event_submitted_by", FFDB_STRING),
  35. array("event_month", FFDB_STRING),
  36. array("event_day", FFDB_INT),
  37. array("event_year", FFDB_INT)
  38. );
  39. // Try and create it...
  40. if (!$db->create("calendar", $schema))
  41. {
  42. echo "Error creating database\n";
  43. return;
  44. }
  45. }
  46.  
  47. function today($record)
  48. { global $event_day;
  49. global $event_month;
  50. global $event_year;
  51.  
  52. //echo "$event_month $event_day $event_year";
  53. if (($record["event_month"] == $event_month) &&
  54. ($record["event_day"] == $event_day) &&
  55. ($record["event_year"] == $event_year))
  56. return true;
  57. return false;
  58. }
  59.  
  60. function show_event($record){
  61. $eventNumber = $record["event_key"];
  62. $eventName = $record["event_name"];
  63. echo "<font class=\"eventLink\">-<a href=\"viewEvent.php?eventNumber=$eventNumber\" class=\"eventLink\">$eventName</a></font> <br>";
  64. }
  65.  
  66. function getEvents(){
  67. global $db;
  68. //get events for today
  69. $result = $db->getbyfunction("today");
  70.  
  71. //display events if there are any
  72. if($result != null)
  73. foreach($result as $item)
  74. show_event($item);
  75. }
  76.  
  77. function days_in_month($_month, $_year)
  78. {
  79.  
  80. if($_month == 2)
  81. { return days_in_feb($_year); }
  82.  
  83. else {
  84.  
  85. if($_month == 1 || $_month == 3 || $_month == 5 || $_month == 7 || $_month == 8 || $_month == 10 || $_month == 12)
  86. { return(31); }
  87. else { return(30); }
  88. }
  89.  
  90. }
  91.  
  92. function selectMonth($_month){
  93.  
  94. $selectstart = "
  95. <select name=\"sent_month\"> ";
  96. $selectend = "
  97. </select>";
  98.  
  99. echo $selectstart;
  100.  
  101. echo "<option value=\"January\"";
  102. if($_month == 1)
  103. echo " selected=\"selected\" ";
  104. echo ">January</option>
  105. ";
  106.  
  107. echo "<option value=\"February\"";
  108. if($_month == 2)
  109. echo " selected=\"selected\" ";
  110. echo ">February</option>
  111. ";
  112.  
  113. echo "<option value=\"March\"";
  114. if($_month == 3)
  115. echo " selected=\"selected\" ";
  116. echo ">March</option>
  117. ";
  118.  
  119. echo "<option value=\"April\"";
  120. if($_month == 4)
  121. echo " selected=\"selected\" ";
  122. echo ">April</option>
  123. ";
  124.  
  125. echo "<option value=\"May\"";
  126. if($_month == 5)
  127. echo " selected=\"selected\" ";
  128. echo ">May</option>
  129. ";
  130.  
  131. echo "<option value=\"June\"";
  132. if($_month == 6)
  133. echo " selected=\"selected\" ";
  134. echo ">June</option>
  135. ";
  136.  
  137. echo "<option value=\"July\"";
  138. if($_month == 7)
  139. echo " selected=\"selected\" ";
  140. echo ">July</option>
  141. ";
  142.  
  143. echo "<option value=\"August\"";
  144. if($_month == 8)
  145. echo " selected=\"selected\" ";
  146. echo ">August</option>
  147. ";
  148.  
  149. echo "<option value=\"September\"";
  150. if($_month == 9)
  151. echo " selected=\"selected\" ";
  152. echo ">September</option>
  153. ";
  154.  
  155. echo "<option value=\"October\"";
  156. if($_month == 10)
  157. echo " selected=\"selected\" ";
  158. echo ">October</option>
  159. ";
  160.  
  161. echo "<option value=\"November\"";
  162. if($_month == 11)
  163. echo " selected=\"selected\" ";
  164. echo ">November</option>
  165. ";
  166.  
  167. echo "<option value=\"December\"";
  168. if($_month == 12)
  169. echo " selected=\"selected\" ";
  170. echo ">December</option>
  171. ";
  172.  
  173.  
  174. echo $selectend;
  175.  
  176. }
  177.  
  178. function selectYear($selectedyear){
  179. $day = getdate();
  180. $year = $day['year'];
  181.  
  182.  
  183. $selectyeartop = "
  184.  
  185. <select name=\"sent_year\">
  186. ";
  187. $selectyearbottom = "
  188. </select>
  189. ";
  190. echo $selectyeartop;
  191.  
  192. for($i=$year; $i<$year+5; $i++) {
  193. echo "<option value=\"$i\"";
  194. if($i == $selectedyear)
  195. echo "selected=\"selected\"";
  196. echo "> $i</option>
  197. ";
  198.  
  199. }
  200.  
  201. echo $selectyearbottom;
  202.  
  203. }
  204.  
  205. function convertMonth($alpha_month){
  206. if($alpha_month == "January")
  207. return 1;
  208. else if($alpha_month== "February")
  209. return 2;
  210. else if($alpha_month== "February")
  211. return 2;
  212. else if($alpha_month== "March")
  213. return 3;
  214. else if($alpha_month== "April")
  215. return 4;
  216. else if($alpha_month== "May")
  217. return 5;
  218. else if($alpha_month== "June")
  219. return 6;
  220. else if($alpha_month== "July")
  221. return 7;
  222. else if($alpha_month== "August")
  223. return 8;
  224. else if($alpha_month== "September")
  225. return 9;
  226. else if($alpha_month== "October")
  227. return 10;
  228. else if($alpha_month== "November")
  229. return 11;
  230. else if($alpha_month== "December")
  231. return 12;
  232.  
  233. return 1;
  234.  
  235. }
  236.  
  237.  
  238. function days_in_feb($year){
  239.  
  240. //$year must be YYYY
  241. //[gregorian] leap year math :
  242.  
  243. if ($year < 0) $year++;
  244. $year += 4800;
  245.  
  246. if ( ($year % 4) == 0) {
  247. if (($year % 100) == 0) {
  248. if (($year % 400) == 0) {
  249. return(29);
  250. } else {
  251. return(28);
  252. }
  253. } else {
  254. return(29);
  255. }
  256. } else {
  257. return(28);
  258. }
  259. }
  260.  
  261.  
  262. /*
  263.   prints the month and year that are passed to it in
  264.   $date
  265. */
  266. function printMonth($_month, $_year)
  267. {
  268.  
  269. $timestamp = mktime(0,0,0,$_month,1,2000);
  270. $date = getdate ($timestamp);
  271. $monthText = $date['month'];
  272.  
  273.  
  274. $monthtext1 =
  275. "
  276. <!-- month heading -------------------------------------------->
  277. <table align=\"center\">
  278. <tr>
  279. <td align=\"left\">
  280. <form name=\"goto\" action=\"calendar.php\" method=\"POST\">
  281. <table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" bgcolor=\"#000000\" align=\"center\">
  282. <tr><td>
  283. <table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" bgcolor=\"#CC0000\">
  284. <tr><td width=\"200\">";
  285.  
  286. $monthtext2 = "<input type=\"image\" src=\"go.gif\" name=\"go\" border=\"0\">
  287.  
  288. </td></tr></table>
  289. </td></tr></table>
  290. </form>
  291. </td>
  292.  
  293. <td align=\"center\" width=\"355\" valign=\"top\"><font class=\"month\">$monthText $_year</font></td>
  294. <td align=\"right\" width=\"186\" valign=\"top\"></td>
  295. </tr>
  296. </table>
  297. <!-- end of month heading ------------------------------------->
  298.  
  299. ";
  300. echo "$monthtext1";
  301. selectMonth($_month);
  302. selectYear($_year);
  303. echo "$monthtext2";
  304. }
  305.  
  306. /*
  307.   prints the bar that contains the days of the week
  308. */
  309. function printDays()
  310. {
  311. $daybar =
  312. "
  313. <!-- days of the week heading --------------------------------->
  314. <table align=\"center\" bgcolor=\"#000000\">
  315. <TR>
  316. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Sunday</font></td>
  317. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Monday</font></td>
  318. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Tuesday</font></td>
  319. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Wednesday</font></td>
  320. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Thursday</font></td>
  321. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Friday</font></td>
  322. <td width=\"105\" align=\"center\" bgcolor=\"#CC0000\"><font class=\"daysfont\">Saturday</font></td>
  323. </tr>
  324.  
  325. <!-- end days of the week heading ----------------------------->
  326.  
  327. ";
  328.  
  329. echo $daybar;
  330. }
  331.  
  332.  
  333. /*
  334.   opens table for calendar which is closed by last week, then prints the first
  335.   week to the calendar
  336. */
  337. function printFirstWeek($_day)
  338. {
  339. global $event_day;
  340. //write table declarations
  341. echo "
  342.  
  343. <!-- begin day boxes ------------------------------------------>
  344.  
  345.  
  346. <tr>
  347.  
  348. ";
  349.  
  350. $current_day = 1;
  351.  
  352. $spot = 0;
  353.  
  354. while ($spot < $_day){
  355.  
  356. echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#e3e3e3\">&nbsp</td>
  357. ";
  358. $spot++;
  359. }
  360.  
  361. while ($spot < 7){
  362. $event_day = $current_day;
  363. echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$current_day</font><br>";
  364. getEvents();
  365. echo "</td>
  366. ";
  367.  
  368. $spot++;
  369. $current_day++;
  370.  
  371. }
  372.  
  373. echo"</tr>
  374. ";
  375.  
  376. return $current_day;
  377. }
  378.  
  379. function printWeek($_day, $_last)
  380. {
  381. global $event_day;
  382.  
  383. while ($_day <= ($_last - 7)){
  384. $count = 0;
  385. echo "<TR>
  386. ";
  387. while($count < 7){
  388. $event_day = $_day;
  389. echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$_day</font><br>";
  390. getEvents();
  391. echo "</td>
  392. ";
  393. $_day++;
  394. $count++;
  395. }
  396. echo "</TR>
  397. ";
  398. }
  399. return $_day;
  400.  
  401. }
  402.  
  403. function printLastWeek($_day, $_lastday)
  404. {
  405. global $event_day;
  406. $count = 0;
  407. echo "<TR>
  408. ";
  409. while($count <= $_lastday)
  410. {
  411. $event_day = $_day;
  412. echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#CCCCCC\"><font class=\"number\">$_day</font><br>";
  413. getEvents();
  414. echo "</td>
  415. ";
  416. $_day++;
  417. $count++;
  418. }
  419.  
  420. while($count < 7)
  421. {
  422. echo "<td width=\"105\" height=\"115\" valign=\"top\" bgcolor=\"#e3e3e3\">&nbsp;</td>
  423. ";
  424. $count++;
  425. $_day++;
  426. }
  427.  
  428. echo "</tr>
  429. ";
  430. echo "</table>
  431. <!-- end day boxes ------------------------------------------>
  432.  
  433. ";
  434. }
  435.  
  436.  
  437.  
  438. //calculate all date information needed
  439. if($sent_month && $sent_year){
  440. $month = convertMonth($sent_month);
  441. $year = $sent_year;
  442. $event_day = 1;
  443. $event_month = $sent_month;
  444. $event_year = $year;
  445. }
  446. else {
  447. $day = getdate();
  448. $month = $month = $day['mon'];
  449. $mday = $mday = $day['mday'];
  450. $year = $year = $day['year'];
  451. $event_day = 1;
  452. $event_month = $day['month'];
  453. $event_year = $year;
  454. }
  455.  
  456.  
  457. $days_in_month = days_in_month ($month, $year);
  458.  
  459. $first_day = mktime(0,0,0,$month,1,$year);
  460. $date_first = getdate ($first_day);
  461.  
  462. $last_day = mktime(0,0,0,$month,$days_in_month,$year);
  463. $date_last = getdate($last_day);
  464.  
  465. $dayofweekfirst = $date_first['wday'];
  466. $dayofweeklast = $date_last['wday'];
  467. //end date calculations
  468.  
  469.  
  470.  
  471.  
  472.  
  473. printMonth($month, $year);
  474. printDays();
  475. $current = printFirstWeek($dayofweekfirst);
  476. $current = printWeek($current, $days_in_month);
  477. printLastWeek($current, $dayofweeklast);
  478.  
  479.  
  480.  
  481. ?>
  482.  
  483. <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>
  484. <table cellpadding="0" cellspacing="0" border="0" align="center">
  485. <tr>
  486. <td width="600" align="center">&nbsp;</td>
  487. </tr>
  488. </table>
  489. </BODY>
  490. </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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

Re: php-calendar

 
-1
  #6
Mar 5th, 2009
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
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!
Attached Files
File Type: txt code.txt (96.9 KB, 0 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,072
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: php-calendar

 
0
  #7
Mar 5th, 2009
you are not initialised or used these variables $sent_month and $sent_year before...what data you want to put in that variable...
refine your code and write coding accordingly....

use code tags....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

Re: php-calendar

 
0
  #8
Mar 6th, 2009
hii
i m designing a php event based calendar
this is my code, can anyone tell me its script code,mine is not working..

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. <link href="style/style.css" rel="stylesheet" type="text/css" />
  7. </head>
  8.  
  9. <body>
  10. <?php
  11. // Get values from query string
  12. $day = $_GET["day"];
  13. $month = $_GET["month"];
  14. $year = $_GET["year"];
  15. $sel = $_GET["sel"];
  16. $what = $_GET["what"];
  17.  
  18. if($day == "")
  19. $day = date("j");
  20.  
  21. if($month == "")
  22. $month = date("m");
  23.  
  24. if($year == "")
  25. $year = date("Y");
  26. $currentTimeStamp = strtotime("$year-$month-$day");
  27. $monthName = date("F", $currentTimeStamp);
  28. $numDays = date("t", $currentTimeStamp);
  29. $counter = 0;
  30. $numEventsThisMonth = 0;
  31. $hasEvent = false;
  32. $todaysEvents = "";
  33.  
  34. <table width='350' border='0' cellspacing='0' cellpadding='0'>
  35. <tr>
  36. <td class='head' width='50'>S</td>
  37. <td class='head' width='50'>M</td>
  38. <td class='head' width='50'>T</td>
  39. <td class='head' width='50'>W</td>
  40. <td class='head' width='50'>T</td>
  41. <td class='head' width='50'>F</td>
  42. <td class='head' width='50'>S</td>
  43. </tr>
  44.  
  45. $numDays = date("t", $currentTimeStamp);
  46. for($i = 1; $i < $numDays+1; $i++, $counter++)
  47. {
  48. $timeStamp = strtotime("$year-$month-$i");
  49.  
  50. if($i == 1)
  51. {
  52. // Workout when the first day of the month is
  53. $firstDay = date("w", $timeStamp);
  54.  
  55. for($j = 0; $j < $firstDay; $j++, $counter++)
  56. echo "<td>&nbsp;</td>";
  57. }
  58.  
  59. if($counter % 7 == 0)
  60. echo "</tr><tr>";
  61.  
  62. echo "<td width='50'>$I</td>";
  63.  
  64. if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
  65. echo "class='weekend'";
  66. else
  67. if($i == date("d") && $month == date("m") && $year == date("Y"))
  68. echo "class='today'";
  69. else
  70. echo "class='normal'";
  71. $monthName = date("F", $currentTimeStamp);
  72.  
  73. <tr>
  74. <td width='50' colspan='1'>
  75. <input type='button' value=' < ' onClick='goLastMonth(<?php echo $month . ", " . $year; ?>)'>
  76. </td>
  77. <td width='250' colspan='5'>
  78. <span class='title'><?php echo $monthName . " " . $year; ?></span><br>
  79. </td>
  80. <td width='50' colspan='1' align='right'>
  81. <input type='button' value=' > ' onClick='goNextMonth(<?php echo $month . ", " . $year; ?>)'>
  82. </td>
  83. </tr>
  84.  
  85. <script>
  86. function goLastMonth(month, year)
  87. {
  88. // If the month is Januaru, decrement the year
  89. if(month == 1)
  90. {
  91. --year;
  92. month = 13;
  93. }
  94.  
  95. document.location.href = 'cal.php?month='+(month-1)+'&year='+year;
  96. }
  97. cal.php?month=12&year=2002
  98. function goNextMonth(month, year)
  99. {
  100. // If the month is December, increment the year
  101. if(month == 12)
  102. {
  103. ++year;
  104. month = 0;
  105. }
  106.  
  107. document.location.href = 'cal.php?month='+(month+1)+'&year='+year;
  108. }
  109.  
  110.  
  111. </script>
  112. <?php
  113. function ReadEvents($Month)
  114. function ReadEvents($Month)
  115. {
  116.  
  117. $theEvents = array();
  118. $eventCounter = 0;
  119.  
  120. // Make sure that the file exists
  121. if(!file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE))
  122. {
  123. $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "w")
  124. or die("<span class='error'>ERROR: Couldn't create events file.</span>");
  125. @fclose($fp);
  126. }
  127. $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "rb")
  128. or die("<span class='error'>ERROR: Couldn't open events file to read events.</span>");
  129. define("EVENT_FILE", "cal_events.text");
  130. while($data = fread($fp, 1024))
  131. {
  132. $events .= $data;
  133. }
  134.  
  135. @fclose($fp);
  136. // Seperate the data into line-seperated arrays
  137. $arrEvents = explode("\r\n", $events);
  138. // Loop through the results and pick the arrays
  139. // that match the selected month
  140. for($i = 0; $i < sizeof($arrEvents); $i+=3)
  141. {
  142. // Get each part of the events date as an index
  143. // of an array
  144. $arrEventDate = explode(" ", $arrEvents[$i]);
  145.  
  146. // If the month is the selected month the grab
  147. // the details of this event
  148. if((int)$arrEventDate[0] == (int)$Month)
  149. {
  150. $theEvents[$eventCounter++] = array("day" => $arrEventDate[1], "name" => $arrEvents[$i+1], "desc" => $arrEvents[$i+2]);
  151. }
  152. }
  153.  
  154.  
  155.  
  156. return $theEvents;
  157. foreach($arrEvents as $eventEntry)
  158. {
  159. if($eventEntry["day"] == $i)
  160. {
  161. // We have at least one event for the day
  162. $hasEvent = true;
  163. $numEventsThisMonth++;
  164. }
  165. }
  166. }
  167.  
  168. // Is it a weekend, does it have events, etc
  169. if($i == $day && $month == date("m") && $year == date("Y") && $sel == 1)
  170. echo "class='selected'";
  171. else if($i == $day && $sel == 1)
  172. echo "class='selected'";
  173. else if($hasEvent == true)
  174. echo "class='event'";
  175. else
  176. if(date("w", $timeStamp) == 0 || date("w", $timeStamp) == 6)
  177. echo "class='weekend'";
  178. else
  179. if($i == date("d") && $month == date("m") && $year == date("Y"))
  180. echo "class='today'";
  181. else
  182. echo "class='normal'";
  183.  
  184. $arrEvents = ReadEvents($month);
  185.  
  186. ...
  187.  
  188. foreach($arrEvents as $eventEntry)
  189. {
  190. if($eventEntry["day"] == $i)
  191. {
  192. // We have at least one event for the day
  193. $hasEvent = true;
  194. $numEventsThisMonth++;
  195.  
  196. if($eventEntry["day"] == $day)
  197. {
  198. // Add the event to the $todaysEvents variable
  199. $todaysEvents .= "<span class='eventTitle'>" . stripslashes($eventEntry["name"]) . "</span>";
  200.  
  201. $todaysEvents .= "<span class='eventDesc'><br>" . stripslashes($eventEntry["desc"]) . "</span><br>";
  202.  
  203. $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>";
  204. }
  205. }
  206. }
  207.  
  208.  
  209.  
  210. if($sel == 1)
  211. {
  212. echo "<tr>";
  213. echo " <td width='350' colspan='7'>";
  214. echo " <hr size='1' color='#CACACA' noshade>";
  215. echo " <span class='Title'>Today's Events</span><br><br>";
  216. echo $todaysEvents;
  217. echo " </td>";
  218. echo "</tr>";
  219. }
  220.  
  221.  
  222. ?>
  223.  
  224. </body>
  225. </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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,744
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 330
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: php-calendar

 
0
  #9
Mar 6th, 2009
Originally Posted by rohnni View Post
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>&nbsp;</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
You just don't learn your lessons ? Do you ? Or are you in 2nd grade ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 58
Reputation: rohnni is an unknown quantity at this point 
Solved Threads: 0
rohnni rohnni is offline Offline
Junior Poster in Training

Re: php-calendar

 
0
  #10
Mar 6th, 2009
wat u mean?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC