Current location: Hot Scripts Forums » Programming Languages » PHP » RSS Feed


RSS Feed

Reply
  #1 (permalink)  
Old 05-17-09, 07:44 AM
connor connor is offline
Wannabe Coder
 
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation RSS Feed

So I am making an RSS feed page for my programs to read off of, I thought I had it working but then I got some errors that I have never had before, nor are they errors that I have programmed in.

Quote:
Error Type: Configuration Error

There was an error on the $conf['debug'] line in your config file.
Warning: Cannot modify header information - headers already sent by (output started at /home/soldiers/public_html/dev/main_site/includes/db.php:70) in /home/soldiers/public_html/dev/main_site/rss.php on line 10
Error Type: Configuration Error

There was an error on the $conf['debug'] line in your config file.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/soldiers/public_html/dev/main_site/includes/db.php on line 40
Error Type: Configuration Error

There was an error on the $conf['debug'] line in your config file.Error Type: Configuration Error

There was an error on the $conf['debug'] line in your config file.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/soldiers/public_html/dev/main_site/includes/db.php on line 40
Error Type: Configuration Error

There was an error on the $conf['debug'] line in your config file.
./rss.php
PHP Code:

<?PHP

define
('__SS',true); // Placing the key.
include("./includes/rss.php");
    
$rss=new RSS();
if(
$_GET['type']=="news"){
    
header("Content-Type: application/xml; charset=ISO-8859-1");
    
$rss->newsFeed();
}else
if(
$_GET['type']=="program"){
    
header("Content-Type: application/xml; charset=ISO-8859-1");
    
$rss->programFeed($_REQUEST['pid']);
}else{
    
$style->head("RSS: Redirect");
    echo 
"<center>Redirecting you to (&quot;./&quot;) in 15 seconds.</center>";
    echo 
'<meta http-equiv="refresh" content="15;url=./">';
    
$style->footer();
}
?>
./includes/rss.php (yes I know Im not pulling everything out of the database yet.
PHP Code:

<?PHP

defined
('__SS') or die(); //If not set kill session.
include("./config.php");
class 
RSS{
    var 
$items   '';
    var 
$details '';
    function 
RSS(){
        include(
"db.php");
        
$this->db=new db($mysql['host'],$mysql['user'],$mysql['pass'],$mysql['db']);
            
$this->db->newconn();
    }
    function 
newsFeed(){
        return 
$this->getDetails("") . $this->getItems();
    }
    function 
programFeed($program){
        return 
$this->getDetails($program) . $this->getItems();
    }
    function 
getDetails($pid){
        
$this->pid=$pid;
        if(
$this->pid==""){
            
$detailsTable="news";
        }else{
            
$detailsTable="program_rss_channel";
        }
        
$this->db->query("SELECT * FROM ".$detailsTable."");
        if(
$this->db->num_rows()>0){
            while(
$row=$this->db->fetch_array()){
                
$cid=$row['id'];
                
$details '<?xml version="1.0" encoding="ISO-8859-1" ?> 
                                <rss version="2.0"> 
                                    <channel> 
                                        <title>'
.$row['title'].'</title> 
                                        <link></link> 
                                        <description></description>'
;
            }
        }else{
            
$details '<?xml version="1.0" encoding="ISO-8859-1" ?> 
                            <rss version="2.0"> 
                                <channel> 
                                    <title>No RSS Feeds</title> 
                                    <link>www.XxxxxxxxXxxxxxx.net</link> 
                                    <description>There are no feeds from this channel at this time.</description>'
;
        }
        return 
$details;
    }
    function 
getItems(){
        if(
$this->pid==""){
            
$itemsTable="news";
        }else{
            
$itemsTable="program_rss_items";
        }        
        
$this->db->query("SELECT * FROM ".$itemsTable."");
        if(
$this->db->num_rows()>0){
            while(
$row=$this->db->fetch_array()){
                
$items .= '<item> 
                    <title>'
$row["title"] .'</title> 
                    <link>'
$row["link"] .'</link> 
                    <description><![CDATA['
$row["description"] .']]></description> 
                </item>'

            }
        }else{
            
$items .= '<item> 
                <title>No RSS Items</title> 
                <link>www.XxxxxxxxXxxxxxx.net</link> 
                <description><![CDATA[There are no items in this channel.]]></description> 
            </item>'

        }
        
$items .= '</channel> 
                </rss>'

        return 
$items;
    }
}
?>
./includes/db.php
PHP Code:

<?PHP

defined
('__SS') or die(); //If not set kill session.
class db{
    var 
$host      "";
    var 
$user      "";
    var 
$pass      "";
    var 
$datb      "";
    var 
$errordesc "";
    var 
$errorno   "";
    
// Query vars
    
var $queryid 0;
    var 
$results = array();
    function 
db($host,$user,$pass,$datb){
        
$this->host=$host;
        
$this->user=$user;
        
$this->pass=$pass;
        
$this->datb=$datb;
    }
    
// Create Database Connection \\
    
function newconn(){
        
$this->connection = @mysql_connect($this->host$this->user$this->pass);
        if(!
$this->connection){
            
$this->error("Couldn't connect to host: ".$this->host."");
        }else
        if(!@
mysql_select_db($this->datb$this->connection)){
            
$this->error("Couldn't connect to database: ".$this->datb."");
        }
    }
    
// Create a Database Query \\
    
function query($query){
        
$this->queryid = @mysql_query($query$this->connection);
        if(!
$this->queryid){
            
$this->error("Couldn't complete query: ".$query);
        }else{        
            return 
$this->queryid;
        }
    }
    
// Count Rows \\
    
function num_rows(){
        
$num=mysql_num_rows($this->queryid);
        if(!
$num){
            
$this->error();
        }else{
            return 
$num;
        }
    }
    
// Fetch an array out of a database \\
    
function fetch_array($id=-1){
        if(
$id==-1){
            
$res=@mysql_fetch_array($this->queryid);
        }else{
            
$res=@mysql_fetch_array($id);
        }
        return 
$res;
    }
    
// Output errors \\
    
function error($str=""){
        
$this->errordesc=mysql_error();
        
$this->errorno=mysql_errno();
        if(
defined('__DEBUG')=="0"){
            echo 
'<script>window.location="./mysql_error.php?from=.'.$_SERVER['REQUEST_URI'].'&en='.$this->errorno.'&ed='.$this->errordesc.'"</script>';
        }else
        if(
defined('__DEBUG')=="1"){
            echo 
"<b>Error Message:</b>&nbsp;".$str."<br><br><b>MySQL Error (#".$this->errorno."):</b>&nbsp;".$this->errordesc."";
        }else{
            echo 
"<b>Error Type:</b>&nbsp;Configuration Error<br><br><b>There was an error on the $conf['debug'] line in your config file.";
        }
    }
}
?>
and finally config.php
PHP Code:

<?PHP

defined
('__SS') or die(); //If not set kill session.
$mysql['host'] = "localhost";
$mysql['db']   = "XXXXXXXXXXXX";  // Masked for obvious reasons.
$mysql['user'] = "XXXXXXXXXXXXXX"// Masked for obvious reasons.
$mysql['pass'] = "XXXXXXXXXXX"// Masked for obvious reasons.
# Debug Options
# $conf['debug'] = "1"; // Displays errors on page. (Distorts Output)
# $conf['debug'] = "0"; // Displays visitor friendly page.
$conf['debug'] = "1";
?>
__________________
Connor Strandt
JCS Photography
www.JCStrandt.com
Reply With Quote
  #2 (permalink)  
Old 05-18-09, 03:10 AM
xLite's Avatar
xLite xLite is offline
Newbie Coder
 
Join Date: Apr 2009
Location: Scotland, United Kingdom
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Put header() in the output buffer to see if that does anything...
PHP Code:

ob_start();
header(" ... ");
ob_flush(); 
Reply With Quote
  #3 (permalink)  
Old 05-18-09, 04:34 AM
connor connor is offline
Wannabe Coder
 
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
That ob_start()/ob_flush() cause just this error:
Quote:
XML Parsing Error: junk after document element
Location: http://dev.xxxxxxxxxxxxxxx.net/main_....php?type=news
Line Number 2, Column 1:<b>Warning</b>: mysql_num_rows(): supplied argument is not a valid MySQL result resource in <b>/home/soldiers/public_html/dev/main_site/includes/db.php</b> on line <b>40</b><br />
^
This is what the page looks like now.
PHP Code:

ob_start();
header("Content-Type: application/xml; charset=ISO-8859-1");
ob_flush();
$rss->programFeed($_REQUEST['pid']); 
__________________
Connor Strandt
JCS Photography
www.JCStrandt.com
Reply With Quote
  #4 (permalink)  
Old 05-19-09, 09:08 PM
connor connor is offline
Wannabe Coder
 
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
I don't see anything wrong with that function as it works in other places.
__________________
Connor Strandt
JCS Photography
www.JCStrandt.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need A Script That Will Populate A Rss Feed Data.txt fredflintstone JavaScript 2 10-21-08 08:20 PM
perl dates (for rss feed) gnznroses Perl 4 11-28-05 01:44 PM
911 Heroes RSS feed websmart Website Reviews 2 03-03-05 12:18 PM
rss feed ??? coldclimber ASP 1 01-05-05 09:10 AM


All times are GMT -5. The time now is 08:36 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.