I am trying to create a rss feed for stored database information with the below script.
This setup works on one of my websites (the same hosting account/server) but will not work on another for some reason. What it does is offers the results in a download instead of displaying them in the browser. (i.e. you try to view the feed: & you download the results) I've had this problem with scripts before when I didn't declare the headers properly, but I can't see the error here.
Also - nothing shows up in the error log.
The .htaccess file:
As I stated, this works on a different website on the same server. . . if anybody sees something, please let me know.
Thanks.
This setup works on one of my websites (the same hosting account/server) but will not work on another for some reason. What it does is offers the results in a download instead of displaying them in the browser. (i.e. you try to view the feed: & you download the results) I've had this problem with scripts before when I didn't declare the headers properly, but I can't see the error here.
Also - nothing shows up in the error log.
Code:
#!/usr/bin/perl
require "/home/example/db.pm";
use CGI::Carp qw(fatalsToBrowser);
#print "content-type: text/html\n\n";
print "content-type: application/rss+xml\n\n";
sub opendb {
use DBI;
$dbh = DBI->connect("DBI:mysql:$dbname:$host","$dbuser","$dbpass");
return; }
sub closedb {
$dbh->disconnect();
return; }
print qq~
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<rss version="2.0">
<channel>
<title>EXAMPLE TITLE</title>
<description>EXAMPLE DESC</description>
<link>[URL unfurl="true"]http://www.example.com</link>[/URL] ~;
&opendb;
$lo = $dbh->prepare("select id,title,description from links order by id DESC");
$lo->execute();
while ($qw = $lo->fetchrow_hashref()) {
$gl_id = $qw->{'id'};
$gl_title = $qw->{'title'};
$gl_description = $qw->{'description'};
$gl_description =~ s|\'|\&\#39\;|g;
print qq~
<item>
<title>$gl_title</title>
<description>$gl_description</description>
<link>[URL unfurl="true"]http://example.com/dl.link?go=$gl_id</link>[/URL]
</item>
~;
}
&closedb;
print qq~
</channel>
</rss>
~;
exit;
The .htaccess file:
Code:
DirectoryIndex index.xml
Options ExecCGI
AddType application/x-httpd-cgi .htm .link .xml
As I stated, this works on a different website on the same server. . . if anybody sees something, please let me know.
Thanks.