Jump to content

[SOLVED] Updating Podcast


Northern Flame

Recommended Posts

I created a podcast,

and i wrote a script that should

update the podcast with information

from a MySQL database whenever

the file is activated.

It doesnt do it though.

Im thinking it is because my

information is in a function,

im not sure,

but here is the script.

 

<?php
mysql_connect("localhost", "user", "pass");
mysql_select_db("db");
$radio = "./../../../radio.xml";
$open_radio = fopen($radio, 'w');
function updateMusic(){
$song_query = mysql_query("SELECT * FROM radio ORDER BY artist");
?>
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
	<title>My Podcast</title>
	<itunes:subtitle>My Podcast</itunes:subtitle>
	<link>http://mywebsite.com/</link>
	<description>My Description</description>
	<language>en</language>
      <itunes:author>Me</itunes:author>
      <itunes:owner>
         <itunes:name>Me</itunes:name>
      </itunes:owner>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<managingEditor>me@website.com (Me)</managingEditor>
	<webMaster>me@website.com</webMaster>
<?php
while($song = mysql_fetch_array($song_query)){
echo '		<item>' . "\n";
echo '			<title>'. $song['name'] . ' - ' . $song['artist'] . '</title>'. "\n";
echo '			<description>'. $song['name'] . ' by ' . $song['artist'] .'</description>'."\n";
echo '			<guid isPermaLink="true">'. $song['link'] .'</guid>'."\n";
echo '			<pubDate>'. date("D, d M Y H:i:s") . '+0000' . '</pubDate>'."\n";
echo '			<enclosure url="'. $song['link'] .'" length="4803811" type="audio/mpeg"/>'."\n";
echo '		</item>'."\n";
}
echo '</channel>'."\n";
echo '</rss>';
}
fwrite($radio, updateMusic()) or die("Could Not Write To File");
fclose($radio);
?>

 

When i run this script I get the die error, could not write to file

Link to comment
Share on other sites

Anyone?

???

I think it is because you cannot have a function in the fwrite() function,

but I dont know,

does anyone know if i can have a function in the fwrite() function

or

does anyone know the solution to my problem?

 

on this line

$open_radio = fopen($radio, 'w');

 

just make it

 

fopen($radio, 'w');

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.