Im trying to make a dynamic rss feed for my site the only problem is that my hosting company wont turn off short tags so i can do so.
The reason i need short tags off is because of the 1st line of xml has <? and ?>
ive tried so many ways to fix it i even email my host to turn them off but they said no... Any Suggestions?
[SOLVED] Xml and PHP
Moderator: General Moderators
[SOLVED] Xml and PHP
Last edited by PrObLeM on Thu Jun 24, 2004 2:04 pm, edited 1 time in total.
Just echo the tags...e.g....
The PHP bbcode tags are screwing with the backslashes??
Code: Select all
echo "<?xml version="1.0" encoding="iso-8859-1"?>\n";the file is rssfeed.php and it gets the username from the folder its being called in.
When i run the script it outputs this (right-click view source)
output to browser
It just doest start xml
When i run the script it outputs this (right-click view source)
Code: Select all
<?xml version="1.0"?>
<rss version="2.0">
<title>PrObLeM's Sp0rklog</title>
<description>Rss Feed From www.sp0rk.com</description>
<link>http://www.sp0rk.com/PrObLeM/</link>
<language>en-us</language><channel>
<item>
<title>Test of news post system</title>
<description>Yes sir the news post system works just fine and dandy!</description>
<link>http://www.sp0rk.com/PrObLeM/</link>
<pubDate>06-23-2004</pubDate>
</item></channel></rss>Code: Select all
Rss Feed From www.sp0rk.com http://www.sp0rk.com/PrObLeM/ en-us Yes sir the news post system works just fine and dandy! http://www.sp0rk.com/PrObLeM/ 06-23-2004It just doest start xml
Code: Select all
<?php
//Includes
include('config.php');
include('classes/db.class.php');
include('classes/error.class.php');
include('classes/template.class.php');
//Objects
//Error
$error = new Error();
//Database
$db = new DataConn($config['dbuname'], $config['dbpass'], $config['dbhost'], $config['dbname']);
//Get Symbolic Link Name
if (eregi('.php', $PHP_SELF))
{
$u_name = explode('/', dirname(substr($PHP_SELF, 0, strpos($PHP_SELF, '.ph'))));
$username = $u_name[(sizeof($u_name)-1)];
}
else
{
$u_name = explode('/', $PHP_SELF);
$username = $u_name[(sizeof($u_name)-2)];
}
$oPut .='<?xml version="1.0"?>
<rss version="2.0">
<title>'.$username.'''s Sp0rklog</title>
<description>Rss Feed From http://www.sp0rk.com</description>
<link>http://www.sp0rk.com/'.$username.'/</link>
<language>en-us</language><channel>';
//////////////////////////////////////////////////////////////////
//Get news
//table = $id_post
$table = $db->oneData("SELECT id FROM users WHERE username='".$username."'") . '_post';
$commenttable = $db->oneData("SELECT id FROM users WHERE username='".$username."'") . '_comments';
$arrayId = explode(',', $db->listTable('id', $table . ' ORDER BY id DESC'));
foreach($arrayId as $id)
{
$postArray = $db->oneAssocArray("SELECT id, subject, dt, body FROM ".$table." WHERE id='".$id."'");
if($postArray['id'] <> '')
{
$oPut .='
<item>
<title>'.$postArray['subject'].'</title>
<description>'.nl2br($postArray['body']).'</description>
<link>http://www.sp0rk.com/'.$username.'/</link>
<pubDate>'. date('m-d-Y', $postArray['dt']). '</pubDate>
</item>';
}
}
$oPut .="</channel></rss>";
echo $oPut;
?>
Last edited by PrObLeM on Thu Jun 24, 2004 1:52 pm, edited 1 time in total.
-
penguinboy
- Forum Contributor
- Posts: 171
- Joined: Thu Nov 07, 2002 11:25 am
well you know how, when you view xml it is formated and has the color syntax this doesnt i mean sure if you rightclick>view source it it looks like so
but if you just view the page it looks like this
Code: Select all
<?xml version="1.0"?>
<rss version="2.0">
<title>PrObLeM's Sp0rklog</title>
<description>Rss Feed From www.sp0rk.com</description>
<link>http://www.sp0rk.com/PrObLeM/</link>
<language>en-us</language><channel>
<item>
<title>Test of news post system</title>
<description>Yes sir the news post system works just fine and dandy!</description>
<link>http://www.sp0rk.com/PrObLeM/</link>
<pubDate>06-23-2004</pubDate>
</item></channel></rss>Code: Select all
Rss Feed From www.sp0rk.com http://www.sp0rk.com/PrObLeM/ en-us Yes sir the news post system works just fine and dandy! http://www.sp0rk.com/PrObLeM/ 06-23-2004