The14thGOD Posted June 22, 2010 Share Posted June 22, 2010 I'm trying to update an RSS feed/xml file with fopen etc but it's not working. The file doesn't even get touched, I sent myself an email with the string and that works. I've changed the path multiple times to try and target it but nothing seems to work. Here's the code: <?php function write_xml_feed() { $xml = '<?xml version="1.0" encoding="utf-8"?> <rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>hidden</title> <link>http://www.me.com/</link> <description> </description> <generator>Feeder 1.4.10(222) http://reinventedsoftware.com/feeder/</generator> <docs>hidden</docs> <language>en</language> <pubDate>'.date('l, d F Y h:i:s').' -0600</pubDate> <lastBuildDate>'.date('l, d F Y h:i:s').' -0600</lastBuildDate>'; //Get items from database that are press releases (ie date != 0000-00-00 $xmlquery = "SELECT title,url,body,DATE_FORMAT(the_date, '%W, %d %M %Y %l:%i:%s') AS display_date FROM website WHERE the_date != 0000-00-00 ORDER BY the_date DESC"; $xmlresults = mysql_query($xmlquery); while($xmlrow = mysql_fetch_assoc($xmlresults)){ $xml.= '<item>'; $xml.= '<title>'.$xmlrow['title'].'</title>'; $xml.= '<link>http://www.me.com/'.$xmlrow['url'].'</link>'; $xml.= '<description><![CDATA['; $xml.= $xmlrow['body']; $xml.= ']]></description>'; $xml.= '<pubDate>'.$xmlrow['display_date'].' -0600</pubDate>'; $xml.= '<guid isPermaLink="false">hidden</guid>'; $xml.= '</item>'; } //closing xml $xml.= '</channel></rss>'; mail('[email protected]','stupid xml',$xml,"From: [email protected]"); //open feed file and overwrite it $handle = fopen('http://me.com/feed.xml','w+'); fwrite($handle,$xml); fclose($handle); return true; } ?> Anyone got any ideas? Thanks for any and all help. Justin P.S. The only other idea i had is that $xml is HUGE, is there an issue/limit with fwrite? (Trying to find the answer via php.net/google) Link to comment https://forums.phpfreaks.com/topic/205583-writting-to-xml-file-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.