Jump to content

writting to xml file not working...


The14thGOD

Recommended Posts

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('justinh@me.com','stupid xml',$xml,"From: justinh@me.com");
	//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
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.