/    Sign up×
Community /Pin to ProfileBookmark

RSS lack of output

Hi, I am using the code below to pull entries from a database depending to each user, but in Firefox is renders an empty page but all the output is in the source. and IE and safari, it breaks.

[url]http://garagesale.gozipline.com/rss,4.xml[/url]

[code=php]<?php

session_start();
header(“Content-Type: text/xml”);
include(“includes/connect.inc.php”);

if(!empty($_GET[‘userid’])){
$userid = $_GET[‘userid’];
}else{
header(“Location: /”);
die;
}

$output = NULL;
$emailqry = $db->query(“SELECT * FROM subscribers WHERE id = ‘{$userid}'”);
$emailrow = $db->fetchRow($emailqry, MDB_FETCHMODE_ASSOC);
$companyqry = $db->query(“SELECT * FROM company WHERE id = ‘{$emailrow[‘company_id’]}'”);
$companyrow = $db->fetchRow($emailqry, MDB_FETCHMODE_ASSOC);
?>
<rss version=”2.0″>
<channel>
<title><?php echo($companyrow[‘company_name’]); ?></title>
<description>Online Listings Finder</description>
<link>http://www.<?php echo($companyrow[‘company_address’]); ?></link>
<copyright><?php echo(date(‘Y’)); ?> <?php echo($companyrow[‘company_name’]); ?></copyright>

<?php

$feedqry = $db->query(“SELECT * FROM subscriptions WHERE rss=’true’ AND userid = ‘{$userid}'”);
$feednum = $db->numRows($feedqry);
while($feedrow = $db->fetchInto($feedqry, MDB_FETCHMODE_ASSOC)){

$datasql = stripslashes($feedrow[‘query’]);
$dataqry = $db->query($datasql);
$datanum = $db->numRows($dataqry);
while($datarow = $db->fetchInto($dataqry, MDB_FETCHMODE_ASSOC)){

$ad = strip_tags($datarow[‘ad’]);
$output .= “<item>”.”n”;
$output .= “<title>{$feedrow[‘title’]}</title>”.”n”;
$output .= “<address>{$datarow[‘address’]}&nbsp;&nbsp;({$datarow[‘region’]})</address>”.”n”;
$output .= “<description>{$ad}</description>”.”n”;
$output .= “<link>$datanum</link>”.”n”;

$output .= “</item>”;
$output .= “nn”;
echo($output);

}
}
?>
</channel>
</rss>[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 20.2007 — You might want to try running the page through the [url=http://validator.w3.org/]validator[/url] and see if it detects any XML structure problems. Also, in Firefox, you might get some useful information by opening up the Tools -> Error Console window.
Copy linkTweet thisAlerts:
@bokehSep 20.2007 — Change all the & signs to &amp;
Copy linkTweet thisAlerts:
@SheldonauthorSep 21.2007 — Ok, I sort of have it working, It returns most things and show's up now at least.

Here is the semi working code if it helps any one else.

[code=php]<?php

session_start();
header("Content-Type: text/xml");
include("includes/connect.inc.php");

if(!empty($_GET['userid'])){
$userid = $_GET['userid'];
}else{
header("Location: /");
die;
}

$output = NULL;
$emailqry = $db->query("SELECT * FROM subscribers WHERE id = '{$userid}'");
$emailrow = $db->fetchRow($emailqry, MDB_FETCHMODE_ASSOC);
$companyqry = $db->query("SELECT * FROM company WHERE id = '{$emailrow['company_id']}'");
$companyrow = $db->fetchRow($emailqry, MDB_FETCHMODE_ASSOC);

echo("<?xml version="1.0" encoding="utf-8"?>"."nn");
?>
<rss version="2.0">
<channel>
<title><?php echo($companyrow['company_name']); ?></title>
<description>Online Listings Finder</description>
<link>http://www.<?php echo($companyrow['company_address']); ?></link>
<copyright><?php echo(date('Y')); ?> <?php echo($companyrow['company_name']); ?></copyright>

<?php

$feedqry = $db->query("SELECT * FROM subscriptions WHERE rss='true' AND userid = '{$userid}'");
$feednum = $db->numRows($feedqry);
while($feedrow = $db->fetchInto($feedqry, MDB_FETCHMODE_ASSOC)){

$datasql = stripslashes($feedrow['query']);
$dataqry = $db->query($datasql);
$datanum = $db->numRows($dataqry);
while($datarow = $db->fetchInto($dataqry, MDB_FETCHMODE_ASSOC)){

$ad = strip_tags($datarow['ad']);
$address = iconv("UTF-8","UTF-8//IGNORE",$feedrow['address']);
$region = iconv("UTF-8","UTF-8//IGNORE",$feedrow['region']);
$ad = iconv("UTF-8","UTF-8//IGNORE",$ad);
$address = str_replace("&", "and", $address);
$region = str_replace("&", "and", $region);
$ad = str_replace("&", "and", $ad);

$output .= "<item>"."n";
$output .= "<title>{$address}</title>"."n";
$output .= "<address>({$region})</address>"."n";
$output .= "<description>{$ad}</description>"."n";
$output .= "<link>$datanum</link>"."n";


$output .= "</item>";
$output .= "nn";
echo($output);

}
}
?>
</channel>
</rss>[/code]
×

Success!

Help @Sheldon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...