PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
vegas22
Forum Newbie
Posts: 10 Joined: Fri Oct 29, 2010 12:00 pm
Post
by vegas22 » Thu Nov 04, 2010 7:44 pm
hello
does anyone know why this isnt showing a feed with any data?
im new to rss and am stuggling!
if someone could correct the code for me id thank them a thousand times!!
Code: Select all
<? header('Content-type: text/xml'); ?>
<rss version="2.0">
<channel>
<title>Name of your site</title>
<description>A description of your site</description>
<link>http://your_home_page_url/</link>
<copyright>Your copyright information</copyright>
<?
$hostname='****'; //// specify host, i.e. 'localhost'
$user='****'; //// specify username
$pass='****'; //// specify password
$dbase='*****'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
$q="SELECT id,jobname,description,postdate FROM jobmodule LIMIT 0,15 ORDER BY postdate DESC";
$doGet=mysql_query($q);
while($result = mysql_fetch_array($doGet)){
?>
<item>
<title> <?=htmlentities(strip_tags($result['jobname'])); ?></title>
<description> <?=htmlentities(strip_tags($result['description'],'ENT_QUOTES'));?></description>
<link>http://yoururl.com/pathtostory/and_page.php?p=<?=$result['id'];?></link>
<pubDate> <?=strftime( "%a, %d %b %Y %T %Z" , $result['postdate']); ?></pubDate>
</item>
<? } ?>
</channel>
</rss>
any help or guidance would be apreciated.
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Thu Nov 04, 2010 7:55 pm
View the source and post it here (use [syntax=xml][/syntax ] tags).
vegas22
Forum Newbie
Posts: 10 Joined: Fri Oct 29, 2010 12:00 pm
Post
by vegas22 » Thu Nov 04, 2010 8:04 pm
Sorry I'm a bit confused. At the moment all i have is the above file and the htaccess file
vegas22
Forum Newbie
Posts: 10 Joined: Fri Oct 29, 2010 12:00 pm
Post
by vegas22 » Thu Nov 04, 2010 8:21 pm
Sorry just understood what you ment. I'm on my phone at moment so I can't view the source but the URL is *****
Last edited by
vegas22 on Thu Nov 04, 2010 8:43 pm, edited 1 time in total.
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Thu Nov 04, 2010 8:35 pm
Code: Select all
<rss version="2.0">
<channel>
<title>Your RSS Feed Name or Website Name</title>
<description>A description of your feed or site.</description>
<link>http://www.yoursite.com/</link>
<copyright>Your copyright details</copyright>
</channel>
</rss>
Well, it doesn't show the "Can't connect to MySQL" or "Can't select database" errors. In the words of Harry Hoo...
Harry Hoo wrote: Two possibilities, Mr. Smart.
One, the query is failing. Place another or die(); at the mysql_query() call.
Code: Select all
$doGet=mysql_query($q) or die('Query failed: ' . mysql_error());
Two, query has no results.
vegas22
Forum Newbie
Posts: 10 Joined: Fri Oct 29, 2010 12:00 pm
Post
by vegas22 » Thu Nov 04, 2010 8:46 pm
ok got it working had an error and needed to remove
ORDER BY postdate DESC
now its working but i have another issue
the layout doesnt work in IE, firefox picks it up of and does a correct layout, any ideas?
thanks again for your help
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Thu Nov 04, 2010 9:07 pm
What do you mean the layout? It doesn't detect it as an RSS feed? If so, could be because you're missing the ...
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
... at the beginning.