I have no problem adding a single event to the calendar. But I am having a problem when adding multiple events with the foreach. Where am I making a mistake? Can you help me?(The dates I pulled from the database are in Y-m-d format.)
errror is "Some events in the calendar file could not be added. The calendar file may be corrupt."
<?php
require_once("zapcallib.php");
include('../dbcon/db.php');
$ical = "BEGIN:VCALENDAR\n
VERSION:2.0\n
PRODID:-//[YOUR WEBSITE], Inc.//EN\n";
foreach($db->query("SELECT * FROM rezervasyondurumu where evid='1'") as $listele) {
$baslangic= $listele['baslangic'];
$bitis= $listele['bitis'];
$ical .= "\nBEGIN:VEVENT";
$ical .= "\nUID: ".$listele['aciklama'] ." fewofethiye.com";
$ical .= "\nDTSTAMP:" . date('Ymd');
$ical .= "\nORGANIZER:catalog@example.com";
$ical .= "\nDTSTART:".date("Ymd", strtotime($baslangic));
$ical .= "\nDTEND:".date("Ymd", strtotime($bitis));
$ical .= "\nSUMMARY:".$listele['aciklama'];
$ical .= "\nDESCRIPTION:" .$listele['aciklama'];
$ical .= "\nEND:VEVENT";
}
$ical .= "\nEND:VCALENDAR";
header("Content-type: text/calendar; charset=utf-8");
header("Content-Disposition: inline; filename=calendar.ics");
echo $ical;
?>