Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Strange error message when generating dynamic iCalendar events

Posted on 2008-06-11
2
Medium Priority
?
312 Views
Last Modified: 2011-10-19
I am using PHP to generate iCalendar events using data from a MySQL DB.  To my eye, the .ics file it generates is well formed, but I keep getting an import error that says "This error can appear if you have attempted to save a recurring Lunar appointment in iCalendar format. To avoid this error, set the appointment option to Gregorian instead of Lunar."  I can not figure out what's wrong.  Below is the code, attached is a sample .ics file that this code generates (in txt format due to upload restrictions).  Any help would be appreciated, thanks!
<?php
    header("Content-Type: text/Calendar");
    header("Content-Disposition: inline; filename=sample.ics");
	
	include_once("config.inc");
	include_once("display-functions.inc");
 
	$intTrainingID=$_REQUEST['id'];
 
	$qr="SELECT * FROM tblTrainingClasses WHERE intTrainingID='$intTrainingID'";
	$result=odbc_exec($dbconn, $qr) or die ("Could not execute query...".obdc_errormsg($dbconn));
  	$intUserID=odbc_result($result,"intUserID");
  	
  	$datClassEnd=odbc_result($result,"datClassEnd");
  	$datRequest=odbc_result($result,"datRequest");
 
	$vCalStart = date("Ymd", strtotime($datClassStart))."T090000";
	$vCalEnd = date("Ymd", strtotime($datClassEnd))."T180000";
?>
BEGIN:VCALENDAR<?="\r\n"?>
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN<?="\r\n"?>
VERSION:2.0<?="\r\n"?>
METHOD:REQUEST<?="\r\n"?>
BEGIN:VEVENT<?="\r\n"?>
DTSTAMP:<?php echo $vCalStart . "Z\r\n"; ?>
DTSTART:<?php echo $vCalStart . "Z\r\n"; ?>
DTEND:<?php echo $vCalEnd . "Z\r\n"; ?>
SUMMARY:<?php echo "sample summary\r\n"; ?>
DESCRIPTION:<?php echo "sample description will be filled in later\r\n"; ?>
UID:123<?="\r\n"?>
X-MICROSOFT-CDO-IMPORTANCE:1<?="\r\n"?>
PRIORITY:3<?="\r\n"?>
CLASS:PUBLIC<?="\r\n"?>
END:VEVENT<?="\r\n"?>
END:VCALENDAR

Open in new window

sample.txt
0
Comment
Question by:lghaman123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 21773165
You might want to lose that VERSION statement.  See the post here:
http://calendarswamp.blogspot.com/2005/08/outlook-2003-for-ical-import-use.html

I've attached my own iCal code below that seems to be working OK.  There are some function calls that may look kind of "pidgin" but I'm sure you will be able to see the patterns OK.

HTH, ~Ray
<?php // LAPRBass vcal_generator.php
$config_page= getcwd() . '/_config.php'; require_once($config_page);
 
$t_key	= get_clean_numeric_string($_GET[t]);
if (!is_numeric($t_key)) { die("Error T"); }
 
$tsql	= "SELECT * FROM {$my_dbt_prefix}_TOURNAMENTS WHERE _key = $t_key LIMIT 1";
if (!$t	= mysql_query("$tsql", $db_connection)) { non_fatal_query_error($tsql); die(); }
if (!$t_rows= mysql_num_rows($t)) { die("Error T=$t_key"); }
$trow	= mysql_fetch_assoc($t);
foreach ($trow as $k => $v) { $$k = stripslashes($v); } 
 
$csql	= "SELECT * FROM {$my_dbt_prefix}_SERIES WHERE _key = $c_key LIMIT 1";
if (!$c	= mysql_query("$csql", $db_connection)) { non_fatal_query_error($csql); die(); }
if (!$c_rows= mysql_num_rows($c)) { die('Error C=$c_key'); }
$crow	= mysql_fetch_assoc($c);
foreach ($crow as $k => $v) { $$k = stripslashes($v); }
 
$p_date		= date('l, F j, Y', strtotime($date));
$p_start	= date('g:ia', strtotime($start));
$p_finish	= date('g:ia', strtotime($finish));
$my_start	= date('D, M j, Y g:ia', strtotime($p_date .' '. $p_start));
 
$vcalstart	= date("Ymd", strtotime($date)) .'T'. date("His", strtotime($start));
$vcalend	= date("Ymd", strtotime($date)) .'T'. date("His", strtotime($finish));
 
$summary	 = "LAPRBASS Tournament: $p_date";
 
$dump		 = "";
$dump		.= "$year $name" . "=0D=0A";
$dump		.= "Mark your calendar for $my_start" . "=0D=0A";
if ($launch != "") { $dump .= "Launch: $launch" . " =0D=0A"; }
if ($title  != "") { $dump .= "$title" . " =0D=0A"; }
$dump		.= "http://www.LAPRBASS.com" . "=0D=0A";
 
$filename = "LAPRBASS" . $t_key . ".vcs";
 
header("Content-Type: text/x-vCalendar");
header("Content-Disposition: inline; filename=$filename");
 
?>
BEGIN:VCALENDAR
VERSION:1.0
PRODID:LAPRBASS Web Calendar
BEGIN:VEVENT
SUMMARY:<?php echo "$summary\n"; ?>
DESCRIPTION;ENCODING=QUOTED-PRINTABLE: <?php echo "$dump\n"; ?>
DTSTART:<?php echo "$vcalstart\n"; ?>
DTEND:<?php echo "$vcalend\n"; ?>
END:VEVENT
END:VCALENDAR

Open in new window

0
 

Author Comment

by:lghaman123
ID: 21823943
Hi Ray, sorry for the delayed response, I got temporarily moved to a different project.  I tried a very similar variation of this code at one point.  After more testing I actually determined that the error was an error being output by my config file which I had included.  This code is definitely working for me now that I fixed my other situation.  Thanks!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question