mikeoffy69 Posted June 19, 2009 Share Posted June 19, 2009 Hello, I am having a error come up when i try to close a task in my calendar. Warning: mktime() expects parameter 4 to be long, string given in D:\wamp\www\support\inc\calendar.php on line 177 This is the code for the line. <?php } elseif ($action=="confirm") { /**/ if ($ddate=="") $ddate=$sdate; //echo $sdate; echo $ddate; $stdate = explode("-",$sdate); $stimestamp = mktime(0, 0, 0, $stdate[0], $stdate[1], $stdate[2]); $dtdate = explode("-",$ddate); $dtimestamp = mktime(0, 0, 0, $dtdate[0], $dtdate[1], $dtdate[2]); if ($stimestamp > $dtimestamp){ die("Error: Start date must be minor to due date. Go back."); } Quote Link to comment Share on other sites More sharing options...
thebadbad Posted June 19, 2009 Share Posted June 19, 2009 If the code works as intended, just remove the warning by typecasting the strings in $stdate and $dtdate to integers (to satisfy mktime() that expects integers): } elseif ($action=="confirm") { /**/ if ($ddate=="") $ddate=$sdate; //echo $sdate; echo $ddate; $stdate = explode("-",$sdate); $stimestamp = mktime(0, 0, 0, (int) $stdate[0], (int) $stdate[1], (int) $stdate[2]); $dtdate = explode("-",$ddate); $dtimestamp = mktime(0, 0, 0, (int) $dtdate[0], (int) $dtdate[1], (int) $dtdate[2]); if ($stimestamp > $dtimestamp){ die("Error: Start date must be minor to due date. Go back."); } The dates are in MM-DD-YYYY format, right? Quote Link to comment Share on other sites More sharing options...
mikeoffy69 Posted June 19, 2009 Author Share Posted June 19, 2009 The dates are in MM-DD-YYYY format, right? Yes it is set up that way. So I have no errors now when clicking on the completed task button. Now the problem is its not recording it and removing it from pending tasks. If I open the task and complete it with in the task it self it works but if I use the short cut it doesn't remove it from pending tasks. if you visit http://www.isolsoft.com/demo/staff/login.php and use staff/demo and goto my tasks you will understand and you can see the error on there page even that we got rid of. Here is the code for that entire calendar page. <?php $header_title = "Calendar"; $techid = $s_userid; $techuser = $s_username; $query = "SELECT * FROM users WHERE id = '$techid'"; $req_tech = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row_tech = mysql_fetch_array($req_tech); if (!$action) {$action="list"; $listed='pending';} ?> <table width="750" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td> <table width="750" border="0" cellspacing="1"> <tr align="center"> <td width="150"> <div class="standard_buttons"><a href="index.php?method=calendar&action=list&listed=pending"><img src="../images/taskpend.gif" align="absmiddle" border="0" alt="Pending Tasks"> Pending Tasks</a></div> </td> <td width="150"> <div class="standard_buttons"><a href="index.php?method=calendar&action=list&listed=overdue"><img src="../images/taskover.gif" align="absmiddle" border="0" alt="Overdue Tasks"> Overdue Tasks</a></div> </td> <td width="150"> <div class="standard_buttons"><a href="index.php?method=calendar&action=list&listed=completed"><img src="../images/taskcompl.gif" align="absmiddle" border="0" alt="Completed Tasks"> Completed Tasks</a></div> </td> <td width="150"> <div class="standard_buttons"><a href="index.php?method=calendar&action=new"><img src="../images/addtask.gif" align="absmiddle" border="0" alt="Add New task"> Add New Task</a></div> </td> <td width="150"> <div class="standard_buttons"><a href="index.php?method=calendar&action=viewcal"><img src="../images/calendar.gif" align="absmiddle" border="0" alt="View Calendar"> View Calendar</a></div> </td> </tr> </table> </td> </tr> </table><br> <?php if ($action=="viewcal") { /* ******************************************************************************** Calendar Navigation variables ******************************************************************************** */ //$myurl=$_SERVER['PHP_SELF']; // the links url is this page in this case $myurl="index.php?method=calendar&action=viewcal"; $yearID=false; // GET variable for the year (set in Active Calendar Class), init false to display current year $monthID=false; // GET variable for the month (set in Active Calendar Class), init false to display current month $dayID=false; // GET variable for the day (set in Active Calendar Class), init false to display current day extract($_GET); /* ******************************************************************************** Create a calendar object ******************************************************************************** */ require_once("calendar_inc.php"); $cal=new activeCalendar($yearID,$monthID,$dayID); /* ******************************************************************************** Gets all dates from your database and set the calendar events html classes (for the layout) ******************************************************************************** */ $tblname="calendar"; // the name of your MySQL Database Table $tblDateName="date"; // the name of your MySQL Table Date Field $tblContent="title"; // the name of your MySQL Table Content Field $tblLink="id"; // the name of your MySQL Table Link Field $sqlID=@mysql_query("SELECT * FROM calendar"); $eventID="event"; // sets the name of the generated HTML class on the event day (css layout) while ($data=@mysql_fetch_array($sqlID, MYSQL_BOTH)){ $mysqlDay=date("j",$data[$tblDateName]); // makes a day out of the database date $mysqlMonth=date("n",$data[$tblDateName]); // makes a month out of the database date $mysqlYear=date("Y",$data[$tblDateName]); // makes a year out of the database date $mysqlContent=$data[$tblContent]; // gets the event content $mysqlLink="index.php?method=calendar&action=view&viewtask=".$data[$tblLink]; // gets the event link $cal->setEvent($mysqlYear,$mysqlMonth,$mysqlDay,$eventID); // set the event, if you want the whole day to be an event $cal->setEventContent($mysqlYear,$mysqlMonth,$mysqlDay,$mysqlContent,$mysqlLink); // set the event content and link } $cal->enableDatePicker(2001,2010); // this enables the month's datepicker (year range 2002 - 2010) $cal->enableMonthNav($myurl); // this enables the month's navigation controls echo $cal->showMonth(); // this displays the month's view }elseif ($action=="list") { if ($listed=='pending'){ $query = "SELECT * FROM calendar WHERE user_id='$techid' AND complete='0' order by id"; $tabletitle = "Pending Tasks"; }elseif ($listed=='overdue'){ $currdate =time(); $query = "SELECT * FROM calendar WHERE user_id='$techid' AND complete='0' AND datedue < '$currdate' order by id"; $tabletitle = "Overdue Tasks"; }elseif ($listed=='completed'){ $query = "SELECT * FROM calendar WHERE user_id='$techid' AND complete='1' order by id"; $tabletitle = "Completed Tasks"; } ?> <table width="600" border="0" cellspacing="0" cellpadding="0" align="center" class="table_border_blue"> <tr> <td> <table width="600" border="0" cellspacing="1"> <tr align="center"> <td class="table_header" colspan="4"> <?php echo $tabletitle; ?> </td> </tr> <tr> <td class="row_caption" align="left"> Title </td> <td class="row_caption"> Date </td> <td class="row_caption"> Due Date </td> <td class="row_caption" width="70"> Actions </td> </tr> <?php //$query = "SELECT * FROM calendar WHERE user_id='$techid' order by id"; $result=mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); while($row = mysql_fetch_array($result)) { ?> <tr> <td class="row_content" align="left"> <?php if ($row["complete"] == 1) {?> <img src="../images/taskcompl.gif" border="0" alt="Completed"> <?php } else {?> <?php $ctime= time(); if ($row["datedue"] < $ctime) {?> <img src="../images/taskover.gif" border="0" alt="Overdue"> <?php } else { ?> <img src="../images/taskpend.gif" border="0" alt="Pending"> <?php } ?> <?php } ?> <a href="index.php?method=calendar&action=view&viewtask=<?php echo $row["id"]; ?>"> <?php echo "<b>$row[title]</b>"; ?> </a> </td> <td class="row_content"> <?php echo date("m-d-Y",$row["date"]); ?> </td> <td class="row_content"> <?php echo date("m-d-Y",$row["datedue"]); ?> </td> <td class="row_caption" width="70" align="center"> <?php if ($listed != 'completed'){ ?> <a href="index.php?method=calendar&action=confirm&compltask=<?php echo $row["id"]; ?>&edit=yes" onClick="return confirm('Mark task as compete?')"><img src="../images/approve.gif" border="0" title="Mark as completed" alt="Mark as completed"></a> <?php } ?> <a href="index.php?method=calendar&action=new&edit=yes&edittask=<?php echo $row["id"]; ?>"><img src="../images/edit.gif" border="0" title="Edit Task" alt="Edit Task"></a> <a href="index.php?method=calendar&action=delete&deltask=<?php echo $row["id"]; ?>" onClick="return confirm('Are you sure to delete this task?')"><img src="../images/delete.gif" border="0" title="Delete Task" alt="Delete Task"></a> </td> </tr> <?php } ?> </table> </td> </tr> </table> <?php } elseif ($action=="confirm") { /**/ if ($ddate=="") $ddate=$sdate; //echo $sdate; echo $ddate; $stdate = explode("-",$sdate); $stimestamp = mktime(0, 0, 0, (int) $stdate[0], (int) $stdate[1], (int) $stdate[2]); $dtdate = explode("-",$ddate); $dtimestamp = mktime(0, 0, 0, (int) $dtdate[0], (int) $dtdate[1], (int) $dtdate[2]); if ($stimestamp > $dtimestamp){ die("Error: Start date must be minor to due date. Go back."); } if ($ticket_id=="") $ticket_id=0; if ($edit=='no'){ $query = "INSERT INTO calendar (complete, user_id, date, datedue, title, content, ticket_id) VALUES ('$complete', '$user_id', '$stimestamp', '$dtimestamp', '$ttitle', '$content', '$ticket_id')"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); echo "<br>The task was added."; } elseif ($edit=='yes'){ if (isset($compltask)){ $query = "UPDATE calendar SET complete='1' WHERE id = '$copmltask'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); echo "<br>The task was completed."; }else{ $query = "UPDATE calendar SET complete='$complete', date ='$stimestamp',datedue ='$dtimestamp', title ='$ttitle', content ='$content', ticket_id ='$ticket_id' WHERE id = '$edittask'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); echo "<br>The task was updated."; } } } elseif ($action=="delete") { $query = "DELETE FROM calendar WHERE id = '$deltask'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); //Show result print("The task has been deleted<br><br>[<a href=\"index.php?method=calendar\">Back</a>]"); } elseif ($action=="view") { $query = "SELECT * FROM calendar WHERE id = '$viewtask'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row = mysql_fetch_array($req); if ($row["completed"] == 0){ }elseif ($row["completed"] == 1){ } ?> <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="table_border_blue"> <tr> <td> <table width="500" border="0" cellspacing="1"> <tr> <td class="table_header" align="center" colspan="2"> View Tasks </td> </tr> <tr> <td class="row_caption" align="right" colspan="2"> <?php if ($row["complete"] == '0'){ ?> <a href="index.php?method=calendar&action=confirm&compltask=<?php echo $row["id"]; ?>&edit=yes" onClick="return confirm('Mark task as compete?')"><img src="../images/approve.gif" border="0" title="Mark as completed" alt="Mark as completed"></a> <?php } ?> <a href="index.php?method=calendar&action=new&edit=yes&edittask=<?php echo $row["id"]; ?>"><img src="../images/edit.gif" border="0" title="Edit Task" alt="Edit Task"></a> <a href="index.php?method=calendar&action=delete&deltask=<?php echo $row["id"]; ?>" onClick="return confirm('Are you sure to delete this task?')"><img src="../images/delete.gif" border="0" title="Delete Task" alt="Delete Task"></a> </td> </tr> <?php if ($row["ticket_id"] !=0){ ?> <tr> <td class="row_caption" valign="top" width="150">Related ticket</td> <td class="row_content"> <?php echo $row["ticket_id"]; ?> <b><a href="index.php?method=viewticket&ticket=<?php echo $row["ticket_id"]; ?>">[View Ticket]</a></b> </td> </tr> <?php } ?> <tr> <td class="row_caption" valign="top" width="150">Start Date</td> <td class="row_content"> <?php echo date("m-d-Y",$row["date"]); ?> </td> </tr> <tr> <td class="row_caption" valign="top" width="150">Due Date</td> <td class="row_content"> <?php echo date("m-d-Y",$row["datedue"]); ?> </td> </tr> <tr> <td class="row_caption" valign="top" width="150">Title</td> <td class="row_content"> <?php echo $row[title]; ?> </td> </tr> <tr> <td class="row_caption" colspan="2">Content</td> </tr> <tr> <td class="row_content" colspan="2"> <?php echo nl2br( htmlspecialchars($row["content"])); ?> </td> </tr> </table> </td> </tr> </table> <?php } elseif ($action=="new") { if ($edit == 'yes'){ $query = "SELECT * FROM calendar WHERE id = '$edittask'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row = mysql_fetch_array($req); $currdate = date("m-d-Y",$row["date"]); $currdatedue = date("m-d-Y",$row["datedue"]); $caption = "Update Task"; $menutitle = "Edit Task"; $ticket_id = $row["ticket_id"]; } else { $edit='no'; $currdate = date("m-d-Y"); $currdatedue = ""; $caption = "Add Task"; $menutitle = "Add New Task"; } ?> <form name="form1" method="POST" action="<?php echo $PHP_SELF; ?>" onSubmit="validateForm('ttitle','','R','Title','content','','R','Content');return document.returnValue"> <table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="table_border_blue"> <tr> <td> <table width="500" border="0" cellspacing="1"> <tr align="center"> <td colspan="2" class="table_header"> <?php echo $menutitle; ?> </td> </tr> <tr> <td width="100" class="row_caption"> Start Date </td> <td class="row_content"><input type="text" name="sdate" id="f_date_c" readonly="1" size="10" value="<?php echo $currdate; ?>" /> <img src="../images/cal.gif" id="f_trigger_c" style="cursor: pointer; border: 1px solid red;" title="Select Start Date" onmouseover="this.style.background='red';" onmouseout="this.style.background=''" /></td> </tr> <tr> <td width="100" class="row_caption"> Due Date </td> <td class="row_content"><input type="text" name="ddate" id="f_date_c2" readonly="1" size="10" value="<?php echo $currdatedue; ?>" /> <img src="../images/cal.gif" id="f_trigger_c2" style="cursor: pointer; border: 1px solid red;" title="Select Due Date" onmouseover="this.style.background='red';" onmouseout="this.style.background=''" /></td> </tr> <tr> <td width="100" class="row_caption"> Title </td> <td width="400" class="row_content"> <input type="text" name="ttitle" size="50" value="<?php echo $row["title"]; ?>"> </td> </tr> <tr> <td valign="top" class="row_caption" colspan="2"> Content </td> </tr> <tr> <td class="row_content" colspan="2"> <textarea name="content" cols="80" rows="10"><?php echo $row["content"]; ?></textarea> </td> </tr> <tr> <td width="100" class="row_caption"> Related to ticket: </td> <td width="400" class="row_content"> ABCDEF-<input type="text" name="ticket_id" size="10" value="<?php if ($ticket_id) echo $ticket_id; ?>"> (Optional) </td> </tr> <tr> <td class="row_content" colspan="2"> <input type="checkbox" class="binput" name="complete" value="1" <?php if ($row["complete"]==1) echo "checked"; ?>> Task Complete </td> </tr> <tr> <td class="row_caption" align="center" colspan="2"><input type="submit" name="Submit" value="<?php echo $caption; ?>" /> <input type="hidden" name="method" value="calendar"> <input type="hidden" name="user_id" value="<?php echo $s_userid?>"> <input type="hidden" name="action" value="confirm"> <input type="hidden" name="edit" value="<?php echo $edit?>"> <?php if ($edit == 'yes'){ ?> <input type="hidden" name="edittask" value="<?php echo $edittask; ?>"> <?php } ?> </td> </tr> </table> </td> </tr> </table> </form> <script type="text/javascript"> Calendar.setup({ inputField : "f_date_c", // id of the input field ifFormat : "%m-%d-%Y", // format of the input field button : "f_trigger_c", // trigger for the calendar (button ID) align : "Tr", // alignment (defaults to "Bl") singleClick : true }); Calendar.setup({ inputField : "f_date_c2", // id of the input field ifFormat : "%m-%d-%Y", // format of the input field button : "f_trigger_c2", // trigger for the calendar (button ID) align : "Br", // alignment (defaults to "Bl") singleClick : true }); </script> <br> <?php } ?> Edit (Daniel0): We have a tag. Use it. It was mentioned in the ToS/rules that you read before you registered (you did read it, right?), so you can't claim ignorance.[/size] Quote Link to comment Share on other sites More sharing options...
mikeoffy69 Posted June 19, 2009 Author Share Posted June 19, 2009 I fixed it. Sloppy coding on there part. Alot of misspelled words. Thanks for help 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.