Easy PHP Calendar

Easy PHP Calendar (http://www.EasyPHPCalendar.com/forums/index.php)
-   General Support (http://www.EasyPHPCalendar.com/forums/forumdisplay.php?f=8)
-   -   Creating a XML File (http://www.EasyPHPCalendar.com/forums/showthread.php?t=5821)

kennyweb 10-10-2006 04:48 PM

Creating a XML File
 
FYI - have created a script to export data base to XML file
Hope this can be helpful to someone else.
:banana:

<?php
// example of connection to a database
$hostname ="remotemysqlhost";
$username ="kenn3_caldlma";
$password ="paswrd";
$dbName = "kenn3_dlmcal";

$conn = mysql_connect($hostname,$username,$password);
mysql_select_db($dbName) or die("Could Not Connect To Database");

// example of querying your table
$query = "select id, startDate, endDate, title, descr, category from epc_calendar";

// example of getting results from query
$result = mysql_query($query,$conn);
if($result) {
// if query ran successfully
// loop over results
//open file to write to
$file_handle = fopen('events.xml','w');

// i normal remove this this line
$xmlPacket = "<?xml version='1.0'?>\n";


//----
$xmlPacket .="<newsblock>\n";

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
// build xml to a variable
$xmlPacket .=
"\n<news>
<active>YES</active>
<id>".$row['id']."</id>
<startdate>".$row['startDate']."</startdate>
<enddate>".$row['endDate']."</enddate>
<title>".$row['title']."</title>
<descr>".$row['descr']."</descr>
<category>".$row['category']."</category>
</news> \n";
}
$xmlPacket .= '</newsblock>';
}
else{
// you probably want to remove this when you are putting this code live.
die('query failed' . mysql_error());

// you can replace it with this:
// which will just build an empty packet rather than killing the process
$xmlPacket = "<?xml version='1.0'?><calendar></calendar>";
}
// write var to file
fwrite($file_handle,$xmlPacket);
fclose($file_handle);
die('Done....');
?>

Brian 10-10-2006 05:57 PM

Thanks for sharing. :)

[Makes into a Sticky]

muskiediver 11-27-2006 03:34 PM

How can you turn this around to import?
 
We create a word document with calendar events, then manually put them one by one into our online calendar. How can you make our word document into an xml file to upload into PHP calendar?

JerryDi 03-25-2008 08:21 AM

I have used this script but get the following error:

XML Parsing Error: no element found
Location: http://www.??????.co.uk/members/calendar/events.xml
Line Number 5, Column 1:

any suggestions ?
rgds
jerry

sobe_punk 04-26-2008 03:57 PM

Quote:

Originally Posted by JerryDi (Post 26743)
I have used this script but get the following error:

XML Parsing Error: no element found
Location: http://www.??????.co.uk/members/calendar/events.xml
Line Number 5, Column 1:

any suggestions ?
rgds
jerry

post your code and i will see if i can offer you any insight into your possible problem if you have yet to figure it out.

I have aquestion myself though... I have ZERO experience with .ics(iCal) filetypes and am looking for a method of querying the DB as it was successfully accomplished by the above script(thanks by the way) and parsing that info into a useable .ics file stored on my server which is the external feed to the (another) Calendar I also use. Anyone have any ideas?

Although it would be very nice, I'm not overly concerned with a 2-way sync, but instead just getting the feed to my (another) Calendar, in turn having it transmitted(auto synced which is already accomplished) to my BlackBerry.


All times are GMT -4. The time now is 09:16 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright 2009 NashTech, Inc.