Jump to content

podcast xml file?


kirks

Recommended Posts

I'm not sure. I'm a newbie at best. Anyway, I want the code that's echoed below to be written to an xml file named path/mypodcast.xml:

 

<?php 
//load database source files
require("../scripts/webcasts.globals.php");
require("../scripts/webcasts.opendb.php");

// Perform database query
$result = mysql_query("SELECT *, date_format(d_Date, '%a. %b %d, %Y') AS date, date_format(d_Date, '%a. ') AS day, date_format(t_Time, '%h:%i') AS time FROM tblWebcasts WHERE i_Id = 1", $connection);
if(!$result) {
die("Database query failed.  Please report this error to web site administrator");
}	
echo ("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n");
echo ("<rss>\n");
echo ("   <channel>\n");
	echo ("   <title>" . $line['c_Title'] . "</title>\n");
echo ("   <description>My description here</description>\n");
echo ("   <link>http://www.mydomain.com</link>\n");
echo ("   <category domain=\"\">Religion & Spirituality:Christianity</category>\n");
echo ("   <copyright>©Copyright name of entity. All Rights Reserved.</copyright>\n");
echo ("   <language>en-us</language>\n");
echo ("   <lastBuildDate>" . $line['date'] . "</lastBuildDate>\n");
echo ("   <managingEditor>[email protected]</managingEditor>\n");
echo ("   <pubDate>" . $line['date'] . "</pubDate>\n");
echo ("   <generator></generator>\n");
echo ("   <item>\n");
echo ("      <title>" . $line['c_Title'] . "</title>\n");
echo ("      <description>description here</description>\n");
echo ("      <link>http://www.mydomain.com/" . $line['c_Filename'] . "</link>\n");
echo ("      <category domain=\"\">Religion & Spirituality:Christianity</category>\n");
echo ("      <enclosure url=\"http://www.mydomain.com" . $line['c_Filename'] . "\" length=\"19409371\" type=\"audio/mpeg\"/>\n");
echo ("      <guid isPermaLink=\"false\">CF1BC542-D123-47B9-8FA8-023A63B719F1</guid>\n");
echo ("      <pubDate>" . $line['date'] . "</pubDate>\n");
echo ("   </item>\n");
echo ("   </channel>\n");
echo ("</rss>\n");


//close database connection
require("../scripts/webcasts.closedb.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/112325-podcast-xml-file/#findComment-576764
Share on other sites

This would work but if not let me know and I'll take another look. (I haven't been able to test it as I'm about to go out!)

 

<?php 
//load database source files
require("../scripts/webcasts.globals.php");
require("../scripts/webcasts.opendb.php");

// Perform database query
$result = mysql_query("SELECT *, date_format(d_Date, '%a. %b %d, %Y') AS date, date_format(d_Date, '%a. ') AS day, date_format(t_Time, '%h:%i') AS time FROM tblWebcasts WHERE i_Id = 1", $connection);

if(!$result) {
die("Database query failed.  Please report this error to web site administrator");
}	


$buff = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
$buff .= "<rss>\n";
$buff .= "  <channel>\n";
$buff .= "   <title>" . $line['c_Title'] . "</title>\n";
$buff .= "   <description>My description here</description>\n";
$buff .= "   <link>http://www.mydomain.com</link>\n";
$buff .= "   <category domain=\"\">Religion & Spirituality:Christianity</category>\n";
$buff .= "   <copyright>©Copyright name of entity. All Rights Reserved.</copyright>\n";
$buff .= "   <language>en-us</language>\n";
$buff .= "   <lastBuildDate>" . $line['date'] . "</lastBuildDate>\n";
$buff .= "   <managingEditor>[email protected]</managingEditor>\n";
$buff .= "   <pubDate>" . $line['date'] . "</pubDate>\n";
$buff .= "   <generator></generator>\n";
$buff .= "   <item>\n";
$buff .= "      <title>" . $line['c_Title'] . "</title>\n";
$buff .= "      <description>description here</description>\n";
$buff .= "      <link>http://www.mydomain.com/" . $line['c_Filename'] . "</link>\n";
$buff .= "      <category domain=\"\">Religion & Spirituality:Christianity</category>\n";
$buff .= "      <enclosure url=\"http://www.mydomain.com" . $line['c_Filename'] . "\" length=\"19409371\" type=\"audio/mpeg\"/>\n";
$buff .= "      <guid isPermaLink=\"false\">CF1BC542-D123-47B9-8FA8-023A63B719F1</guid>\n";
$buff .= "      <pubDate>" . $line['date'] . "</pubDate>\n";
$buff .= "   </item>\n";
$buff .= "   </channel>\n";
$buff .= "</rss>\n";

$f = fopen("path/somefile.xml", "w");

if ($f)
{
	 fwrite($f, $buff);
  $f =  fclose($f);
}

//close database connection
require("../scripts/webcasts.closedb.php");
?>

Link to comment
https://forums.phpfreaks.com/topic/112325-podcast-xml-file/#findComment-576796
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.