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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |