I created RSS from mysql database using php.
Here is some notes for myself in the future if I have to troubleshoot again.
You can make PHP file produce xml by putting this in the beginning of the code,
<?php header('Content-type: text/xml', true);
echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?>
- Check it using W3C Feed Validation Service
- pubDate needs to be RFC-822 date-time. My database stored the time in regular timestamp in yyyy-mm-dd hh:mm:ss, such as 2009-11-27 20:00:17.
All I had to do was this: ($myTime is “2009-11-27 20:00:17″)
$date_rfc822 = date(r,$myTime);
- centricle.com’s Encode / Decode HTML Entities is awesome.
- Some php functions that I have used for this project:
preg_replace Regular expression to replace string… I need to study this more. Here is one reference.
trim remove unwanted spaces form the string.
stripos Check to see if a phrase/word exist in a string
$text = strip_tags($text);
$text = stripslashes($text);
$text = preg_replace('/\s\s+/', ' ', $text);
$text = trim($text);
$myText = mysql_real_escape_string($strText,$db_handle);
$modDate = strtotime($strDate);