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>[email protected] (Me)</managingEditor>
	<webMaster>[email protected]</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
https://forums.phpfreaks.com/topic/76793-solved-updating-podcast/
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');

 

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.