Can I get some help with this. This code used to create the RSS feed properly, but for some reason now it is not doing so. It is not displaying the articles in descending order by date anymore. Here is the feed http://www.financenewstoday.com/rss.php Here is the code: function showSectionRSS($folder) { global $art_reader; $articles = ""; $q = mysql_query("select * from sections where folder like '".$folder."%' order by folder"); while ($fq=mysql_fetch_object($q)) { //print "id:" . $fq->id; $sql = "select * from articles where zones like '%[".$fq->id."]%' and status='Publish' order by headline_date desc limit 5"; //print $sql; $q2 = mysql_query($sql); while ($fq2=mysql_fetch_object($q2)) { $q_str .= "'" . $fq2->id . "',"; //$s_str .= "'" . $fq->folder . "',"; $s_str .= $fq->folder . ","; } // print $q_str; } $q_str = substr($q_str,0,strlen($q_str)-1); //remove last comma $s_str = substr($s_str,0,strlen($s_str)-1); //ok now we have all ids in an array. Let's try to sort by date // print 'q:' .$q_str; //list($arr) = explode(",", $q_str); $sql = "select distinct a.headline,a.id, a.headline_date,a.summary,a.zones from articles a where a.id IN (" .$q_str. ") order by headline_date desc limit 25"; //print $sql; $q = mysql_query($sql); while ($fq=mysql_fetch_object($q)) { $mainz = explode("]",$fq->zones); $mainz = $mainz[0]; $mainz = str_replace("[","",$mainz); $sql2 = "select * from sections where id='".$mainz."'"; $q3 = mysql_query($sql2); $fq3 = mysql_fetch_object($q3); $articles .= "<item>\n"; $articles .= "<title>".stripslashes($fq->headline)."</title>\n"; $articles .= "<link>http://www.financenewstoday.com" .$fq3->folder. $art_reader. "?pg=ShowArticle&aID=" . $fq->id . "</link>"; $articles .= "<description>".stripslashes($fq->summary)."</description>\n"; $articles .= "<guid isPermaLink='true'>http://www.financenewstoday.com" .$fq3->folder. $art_reader. "?pg=ShowArticle&aID=" . $fq->id . "</guid>\n"; //date('l, F d, Y',time()) $articles .= "<pubDate>".date('r',strtotime($fq->headline_date))."</pubDate>\n"; $articles .= "</item>\n"; } return $articles; } PHP:
First, use a proper data access API, such as mysqli (MySQL only, PHP 4+); PDO (multi-DB, PHP 5+); or PEAR::MDB2 (multi-DB, PHP 4). These allow you to use parameterised queries, which avoids any risk of SQL injection, and generally makes for a better experience for all involved. Next, have you run the SQL queries in a tool such as phpMyAdmin or the MySQL console (if available)? If so, do they produce the correct results?
The programmer I hired wrote the code, but now I can't get him to return my emails. So I'm trying to fix it on my own. I was hoping someone who knew what they were looking at, could point out how to fix it.
You didn't answer my question. I know what I'm looking at, and it doesn't help much, which is why I asked.