Bluehost.com Web Hosting $6.95

RSS Feed using PHP/MySQL errors

This is a discussion on RSS Feed using PHP/MySQL errors within the PHP General forums, part of the PHP Programming Forums category; Trying to create an articles rss feed for my site and I keep getting an error that says: ===== A semi ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-06-2008
Don Mak
 
Posts: n/a
Default RSS Feed using PHP/MySQL errors

Trying to create an articles rss feed for my site and I keep getting an
error that says:

=====
A semi colon character was expected.
Line: 7 Character: 60
<link>http://www.chirunning.com/shop/pages.php?pageid=19&id=383</link>
=====

I've tried every way imaginable to figure out why I am getting this error,
finally I needed to post it to get some feedback. I put an ARROW at the end
of the line in question below. Thanks in advance for any insight you can
provide.

<?php
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

// Set RSS version.
echo "<rss version=\"2.0\"> ";

// Start the XML.
echo "
<channel>
<title>Articles Feed</title>
<description>Latest Articles</description>
<link>http://www.mydomain.com/shop/pages.php?pageid=17</link>";

// Create a connection to your database.
//require("db_connection.php");

@mysql_connect('localhost', 'xxxxx', 'xxxxx') or die('ERROR--CAN'T CONNECT
TO SERVER');
@mysql_select_db('shop') or die('ERROR--CAN'T CONNECT TO DB');

$masterQuery="SELECT articleid, the_date, title FROM mytable WHERE type = 1
ORDER BY the_date DESC";


// Query database and select the last 10 entries.
$data = mysql_query($masterQuery);
while($row = mysql_fetch_array($data))
{

// Convert database images data into actual image link.
$row[Intro] = str_replace("images/", "http://www.mydomain.com/images/",
$row[Intro]);

// Continue with the 10 items to be included in the <item> section of the
XML.
echo "
<item>
<link>http://www.mydomain.com/shop/pages.php?pageid=19&id=".$row[articleid]."</link>
<!---ERROR!
<guid isPermaLink=\"true\">
http://www.mydomain.com/shop/pages.php?pageid=18&id=
".$row[articleid]."</guid>
<title>".$row[chi_title]."</title>
</item>";
}

// substr can limit the number of characters. First number is starting point
while the second number is number of characters.
// otherwise just use $row[Intro].
// <guid> is an optional sub-element of <item> but recommended if you don't
want to receive a warning when validating your RSS.
echo "</channel></rss>";
?>

DM

Reply With Quote
  #2 (permalink)  
Old 08-07-2008
Peter Ford
 
Posts: n/a
Default Re: RSS Feed using PHP/MySQL errors

Don Mak wrote:
> Trying to create an articles rss feed for my site and I keep getting an
> error that says:
>
> =====
> A semi colon character was expected.
> Line: 7 Character: 60
> <link>http://www.chirunning.com/shop/pages.php?pageid=19&id=383</link>
> =====
>


This is an easy one: in both of the following lines

@mysql_connect('localhost', 'xxxxx', 'xxxxx') or die('ERROR--CAN'T CONNECT
TO SERVER');
@mysql_select_db('shop') or die('ERROR--CAN'T CONNECT TO DB');

you have an unescaped "'" in the die() message.

Suggest you use one of:

die("ERROR--CAN'T CONNECT TO SERVER");
die('ERROR--CAN\'T CONNECT TO SERVER');
die('ERROR--CANNOT CONNECT TO SERVER'); // English is a very powerful language!!

and similar for the other message...


There may be other errors in your code, but that's all you were asking about.



--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:11 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0