Northern Flame Posted November 10, 2007 Share Posted November 10, 2007 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 Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted November 10, 2007 Author Share Posted November 10, 2007 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? Quote Link to comment Share on other sites More sharing options...
atlanta Posted November 10, 2007 Share Posted November 10, 2007 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'); Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted November 10, 2007 Author Share Posted November 10, 2007 nope, still not working, this is the error i get Warning: fwrite(): supplied argument is not a valid stream resource in /my/path/update.php on line 37 Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted November 10, 2007 Author Share Posted November 10, 2007 oh never mind i found the problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.