Welcome Guest, Not a member yet? Register   Sign In
RSS FEED from derekallard.com Problem at server
#1

[eluser]Asinox[/eluser]
Hi, i tried the RSS Feed of Derekallard.com, and in my local machine the feed is fine, but in my server i got the error:

Code:
A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/nxmedia/public_html/raptitud/system/application/controllers/feed.php:23)

Filename: libraries/Session.php

Line Number: 662

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/nxmedia/public_html/raptitud/system/application/controllers/feed.php:23)

Filename: controllers/feed.php

Line Number: 19

Now the controller Feed:
Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Feed extends Controller{

    function Feed(){
        parent::Controller();
    }
    
    function index(){
        $data['encoding'] = 'utf-8';
        $data['feed_name'] = 'raptitud.com';
        $data['feed_url'] = 'http://www.raptitud.com';
        $data['page_description'] = 'Hip Hop Global desde la Republica Dominicana';
        $data['page_language'] = 'es-ES';
        $data['creator_email'] = 'webmaster [arroba] raptitud [punto] com';
        $data['posts'] = $this->modarticulos->getRecentPosts();    
        header("Content-Type: application/rss+xml"); //HERE IS THE LINE 19
        $this->load->view('feed/rss', $data);
    }
}

Somebody know why? Sad

Thanks for see.
#2

[eluser]TheFuzzy0ne[/eluser]
That's usually a sign that you have a space before an opening PHP tab, or after a closing one. Also, be sure you're not echoing something.

I assume you're code has PHP tags (as I don't see any above). If so, you can omit the closing PHP tag completely.
#3

[eluser]Asinox[/eluser]
yes, that was true... space before
Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Thanks
#4

[eluser]Asinox[/eluser]
but know i have another problem Sad with the view

Google Crhome said:
Code:
error on line 1 at column 35: parsing XML declaration: '?>' expected

Code:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    &lt;title&gt;&lt;?php echo $feed_name; ?&gt;&lt;/title&gt;

    &lt;link&gt;&lt;?php echo $feed_url; ?&gt;&lt;/link&gt;
    <description>&lt;?php echo $page_description; ?&gt;</description>
    <dc:language>&lt;?php echo $page_language; ?&gt;</dc:language>
    <dc:creator>&lt;?php echo $creator_email; ?&gt;</dc:creator>

    <dc:rights>Copyright &lt;?php echo gmdate("Y", time()); ?&gt;</dc:rights>
    <admin:generatorAgent rdf:resource="http://www.raptitud.com/" />

    &lt;?php foreach($posts->result() as $entry): ?&gt;
    
        <item>

          &lt;title&gt;&lt;?php echo xml_convert($entry->titulo); ?&gt;&lt;/title&gt;
          &lt;title&gt;&lt;?php echo site_url('site/articulo/' . $entry->articulo_id) ?&gt;&lt;/title&gt;
          &lt;link&gt;&lt;?php echo site_url('site/articulo/' . $entry->articulo_id) ?&gt;&lt;/link&gt;


          <description>&lt;![CDATA[
      &lt;?= str_replace('/public/uploads/thumbs/', base_url() . 'public/uploads/thumbs/', $entry->contenido); ?&gt;
      ]]></description>
      <pubDate>&lt;?php echo date ('r', $entry->date);?&gt;</pubDate>
        </item>

        
    &lt;?php endforeach; ?&gt;
    
    </channel></rss>

Where is the problem Sad
#5

[eluser]TheFuzzy0ne[/eluser]
Try adding a space before the closing tag:
Code:
&lt;?php
echo '&lt;?xml version="1.0" encoding="utf-8" ?&gt;' . "\n";
?&gt;
#6

[eluser]Asinox[/eluser]
[quote author="TheFuzzy0ne" date="1237317255"]Try adding a space before the closing tag:
Code:
&lt;?php
echo '&lt;?xml version="1.0" encoding="utf-8" ?&gt;' . "\n";
?&gt;
[/quote]

Thanks, but is not working, the same thing Sad
#7

[eluser]Asinox[/eluser]
fixed:

Code:
echo '&lt;?xml version="1.0" encoding="utf-8" '. "?" .'>' . "\n";
#8

[eluser]Asinox[/eluser]
now i have another problem with this line
Code:
<pubDate>&lt;?php echo date('r', $entry->date);?&gt;</pubDate>
error
Code:
<pubDate><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  A non well formed numeric value encountered</p>
<p>Filename: libraries/Loader.php(673) : eval()'d code</p>
<p>Line Number: 34</p>

</div>1969-12-31T20:33:29-04:00</pubDate>

Why use "r"???? the date field in my table is like 2009-03-10 12:10:04, why the error?, the "r" is optional?

thanks
#9

[eluser]attos[/eluser]
You can use the predefined DATE_RSS or DATE_ATOM constants instead of 'r' in your view:

Code:
<pubDate>&lt;?php echo date(DATE_RSS, $entry->date);?&gt;</pubDate>

(From the PHP Manual)
#10

[eluser]Asinox[/eluser]
Thanks attos but the same error again Sad
Code:
<pubDate><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  A non well formed numeric value encountered</p>
<p>Filename: libraries/Loader.php(673) : eval()'d code</p>
<p>Line Number: 34</p>

</div>Wed, 31 Dec 1969 20:33:29 -0400</pubDate>




Theme © iAndrew 2016 - Forum software by © MyBB