SueBee710
07-11-2012, 12:24 AM
I am new to php coding and have created a calendar. When I add a new event, I get the following error, though teh new event is added to the calendar.
Warning: mktime() expects parameter 6 to be long, string given in C:\wamp\www\Project 3\SimpleCalendar\view.php on line 21
Here is my code - with line 21 marked:
<?php
session_start();
require("config.php");
if(isset($_SESSION['LOGGEDIN']) == FALSE) {
header("Location: " . $config_basedir);
}
function short_event($name) {
$final = "";
$final = (substr($name, 0, 12) . "...");
return $final;
}
require("header.php");
if(isset($_GET['error'])) {
echo "<script>newEvent('" . $_GET['eventdate'] . "', 1)</script>";
}
$cols = 7;
$weekday = date("w", mktime(0, 0, 0, $month, 1, $year)); // line 21
$numrows = ceil(($numdays + $weekday) / $cols);
echo "<br />";
echo "<table class='cal' cellspacing=0 cellpadding=5 border=1>";
echo "<tr>";
echo "<th class='cal'>Sunday</th>";
echo "<th class='cal'>Monday</th>";
echo "<th class='cal'>Tuesday</th>";
echo "<th class='cal'>Wednesday</th>";
echo "<th class='cal'>Thursday</th>";
echo "<th class='cal'>Friday</th>";
echo "<th class='cal'>Saturday</th>";
echo "</tr>";
$counter = 1;
$newcounter = 1;
echo "<tr>";
$daysleft = 6 - $weekday--;
for($f=0;$f<=$weekday;$f++) {
echo "<td class='cal_date' width='110' height='10'>";
echo "</td>";
}
for($f=0;$f<=$daysleft;$f++) {
echo "<td class='cal_date' width='100' height='10'>";
$display = date("jS", mktime(0, 0, 0, $month, $counter, $year));
$todayday = date("d");
$todaymonth = date("n");
$todayyear = date("Y");
if($counter == $todayday AND $month == $todaymonth AND
$year == $todayyear) {
echo "<strong>TODAY " . $display . "</strong>";
}
else {
echo $display;
}
echo "</td>";
$counter++;
}
echo "</tr>";
echo "<tr>";
for($f=0;$f<=$weekday;$f++) {
echo "<td class='cal' width='110' height='10'>";
if($newcounter <= $numdays) {
}
echo "</td>";
}
for($f=0;$f<=$daysleft;$f++) {
echo "<td class='cal' width='110' height='40'>";
$date = $year . "-" . $month . "-" . $newcounter;
echo "<a class='cal' href='#' onclick=\"newEvent('" . $date . "')\"></a>";
$eventsql = "SELECT * FROM events WHERE date = '" . $date . "';";
$eventres = mysql_query($eventsql);
while($eventrow = mysql_fetch_assoc($eventres)) {
echo "<a class='deleteevent' href='delete.php?id=" . $eventrow['id'] . "' onclick=\"return confirm('Are you sure you want to delete `" . $eventrow['name'] ."`?');\">X</a>";
echo "<a class='event' href='#' onclick='getEvent(" . $eventrow['id'] . ")'>" . short_event($eventrow['name']) . "</a><br />";
}
echo "</td>";
$newcounter++;
}
echo "</tr>";
for($i=1;$i<=($numrows-1);$i++) {
echo "<tr>";
for($a=0;$a<=($cols-1);$a++) {
echo "<td class='cal_date' width='110' height='10'>";
$display = date("jS", mktime(0, 0, 0, $month, $counter,
$year));
$todayday = date("d");
$todaymonth = date("n");
$todayyear = date("Y");
if($counter == $todayday AND $month == $todaymonth AND
$year == $todayyear) {
echo "<strong>TODAY " . $display . "</strong>";
}
else {
echo $display;
}
echo "</td>";
$counter++;
}
echo "</tr>";
echo "<tr>";
for($aa=1;$aa<=$cols;$aa++) {
echo "<td class='cal' width='110' height='40'>";
if($newcounter <= $numdays) {
$date = $year . "-" . $month . "-" . $newcounter;
echo "<a class='cal' href='#' onclick=\"newEvent('" . $date . "')\"></a>";
$eventsql = "SELECT * FROM events WHERE date = '" . $date . "';";
$eventres = mysql_query($eventsql);
while($eventrow = mysql_fetch_assoc($eventres)) {
echo "<a class='deleteevent' href='delete.php?id=" . $eventrow['id'] . "' onclick=\"return confirm('Are you sure
you want to delete `" . $eventrow['name'] ."`?');\">X</a>";
echo "<a class='event' href='#' onclick='getEvent(" . $eventrow['id'] . ")'>" . short_event($eventrow['name']) . "</a><br />";
}
}
echo "</td>";
$newcounter++;
}
echo "</tr>";
}
echo "</table>";
require("footer.php");
?>
Can anyone tell me is causing the error and how to fix it?
Thanks - SueBee710
Warning: mktime() expects parameter 6 to be long, string given in C:\wamp\www\Project 3\SimpleCalendar\view.php on line 21
Here is my code - with line 21 marked:
<?php
session_start();
require("config.php");
if(isset($_SESSION['LOGGEDIN']) == FALSE) {
header("Location: " . $config_basedir);
}
function short_event($name) {
$final = "";
$final = (substr($name, 0, 12) . "...");
return $final;
}
require("header.php");
if(isset($_GET['error'])) {
echo "<script>newEvent('" . $_GET['eventdate'] . "', 1)</script>";
}
$cols = 7;
$weekday = date("w", mktime(0, 0, 0, $month, 1, $year)); // line 21
$numrows = ceil(($numdays + $weekday) / $cols);
echo "<br />";
echo "<table class='cal' cellspacing=0 cellpadding=5 border=1>";
echo "<tr>";
echo "<th class='cal'>Sunday</th>";
echo "<th class='cal'>Monday</th>";
echo "<th class='cal'>Tuesday</th>";
echo "<th class='cal'>Wednesday</th>";
echo "<th class='cal'>Thursday</th>";
echo "<th class='cal'>Friday</th>";
echo "<th class='cal'>Saturday</th>";
echo "</tr>";
$counter = 1;
$newcounter = 1;
echo "<tr>";
$daysleft = 6 - $weekday--;
for($f=0;$f<=$weekday;$f++) {
echo "<td class='cal_date' width='110' height='10'>";
echo "</td>";
}
for($f=0;$f<=$daysleft;$f++) {
echo "<td class='cal_date' width='100' height='10'>";
$display = date("jS", mktime(0, 0, 0, $month, $counter, $year));
$todayday = date("d");
$todaymonth = date("n");
$todayyear = date("Y");
if($counter == $todayday AND $month == $todaymonth AND
$year == $todayyear) {
echo "<strong>TODAY " . $display . "</strong>";
}
else {
echo $display;
}
echo "</td>";
$counter++;
}
echo "</tr>";
echo "<tr>";
for($f=0;$f<=$weekday;$f++) {
echo "<td class='cal' width='110' height='10'>";
if($newcounter <= $numdays) {
}
echo "</td>";
}
for($f=0;$f<=$daysleft;$f++) {
echo "<td class='cal' width='110' height='40'>";
$date = $year . "-" . $month . "-" . $newcounter;
echo "<a class='cal' href='#' onclick=\"newEvent('" . $date . "')\"></a>";
$eventsql = "SELECT * FROM events WHERE date = '" . $date . "';";
$eventres = mysql_query($eventsql);
while($eventrow = mysql_fetch_assoc($eventres)) {
echo "<a class='deleteevent' href='delete.php?id=" . $eventrow['id'] . "' onclick=\"return confirm('Are you sure you want to delete `" . $eventrow['name'] ."`?');\">X</a>";
echo "<a class='event' href='#' onclick='getEvent(" . $eventrow['id'] . ")'>" . short_event($eventrow['name']) . "</a><br />";
}
echo "</td>";
$newcounter++;
}
echo "</tr>";
for($i=1;$i<=($numrows-1);$i++) {
echo "<tr>";
for($a=0;$a<=($cols-1);$a++) {
echo "<td class='cal_date' width='110' height='10'>";
$display = date("jS", mktime(0, 0, 0, $month, $counter,
$year));
$todayday = date("d");
$todaymonth = date("n");
$todayyear = date("Y");
if($counter == $todayday AND $month == $todaymonth AND
$year == $todayyear) {
echo "<strong>TODAY " . $display . "</strong>";
}
else {
echo $display;
}
echo "</td>";
$counter++;
}
echo "</tr>";
echo "<tr>";
for($aa=1;$aa<=$cols;$aa++) {
echo "<td class='cal' width='110' height='40'>";
if($newcounter <= $numdays) {
$date = $year . "-" . $month . "-" . $newcounter;
echo "<a class='cal' href='#' onclick=\"newEvent('" . $date . "')\"></a>";
$eventsql = "SELECT * FROM events WHERE date = '" . $date . "';";
$eventres = mysql_query($eventsql);
while($eventrow = mysql_fetch_assoc($eventres)) {
echo "<a class='deleteevent' href='delete.php?id=" . $eventrow['id'] . "' onclick=\"return confirm('Are you sure
you want to delete `" . $eventrow['name'] ."`?');\">X</a>";
echo "<a class='event' href='#' onclick='getEvent(" . $eventrow['id'] . ")'>" . short_event($eventrow['name']) . "</a><br />";
}
}
echo "</td>";
$newcounter++;
}
echo "</tr>";
}
echo "</table>";
require("footer.php");
?>
Can anyone tell me is causing the error and how to fix it?
Thanks - SueBee710