Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

problem with rss in php

Featured Replies

<?php
echo '<?xml version="1.0" ?>';
echo '<rss version="2.0">';

echo '<channel>'; // Opens our main content
echo '<title>Test Website RSS Feed</title>';    // Defines the title of the RSS feed
echo '<link>http://www.testsite.com</link>';    // Where the RSS feed is from
echo '<description>This RSS feed is all about the pie.</description>'; // What its about

$c = mysqli_connect('localhost', '', '', '') or die(mysqli_error($c)); // Connect with our information
$q = mysqli_query($c, 'SELECT * FROM news ORDER BY id DESC LIMIT 5') or die(mysqli_error($c)); // Query the table for 5 news articles sorting by 'id'
while($r = mysqli_fetch_assoc($q)) // While there is more rows to get (max of 5) we get an associative array
{

echo '<item>'; // Begin a news article
echo '<title>'.$r['title'].'</title>'; // Give it a title
echo '<link>'.$r['permalink'].'</link>'; // The link to the article
echo '<description>'.$r['content'].'</description>'; // The description or content of the article
echo '<author>'.$r['author'].'</author>'; // The author
echo '<pubDate>'.$r['date'].'</pubDate>'; // The date is was published
echo '</item>'; // End news article
} // End while statement

echo '</channel>';
echo '</rss>';
/>

 

im confused as when i load it up i get an error saying

 

"XML Parsing Error: no element found

Location: http://www.quad.co.uk/test1.xml

Line Number 27, Column 3:?>

--^"

 

where could i be going wrong?

 

thanks in advance

Have you seen the source code?

When I load that page in Firefox - I get an error as you explained. And when I view the source I see the full PHP code.

 

That tells me that PHP isn't enabled for your website.

  • Author

thats because its a .xml file and not .php

 

i have www.getrecognized.co.uk/test1.php also that shows some data but doesnt come up right

 

confused

Two problems:

1)

You've encoded all the angle brackets < and > as < and >

 

2)

By default .PHP files are normally set up to be treated with text/html MIME type. Before you output any data - send an HTTP header to identify the document as RSS XML.

header('Content-Type: application/rss+xml');

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.