Reply to Re: create rss xml

Your name:

Reply:


Posted by Jerry Stuckle on 02/05/07 11:35

Caine,

Some interspaced comments. Probably not all of the errors, but it
should give you a start.

caine wrote:
> I'm currently working on creating the xml feed since I had data ready
> in my database after web data extraction. However, it has errors for
> this line:
>
> <xml version="1.0" encoding="ISO-8859-1">
>
> I was unable to solve this.
>
> <html>
> <head>
> <title>MMU RSS FEED</title>
> </head>
> <body>
>
> header("Content-type: application/xml");
>

Is this supposed to be a PHP statement? If so, it won't work here.

It must be within <?php ... ?> tags, and must appear before any output
(including the <html> tag, any whitespace, etc.).

>
> <xml version="1.0" encoding="ISO-8859-1">
>

Should be <?xml ...?>.

> <rss version ="2.0">
>
>
> <channel>
> <title>MMU RSS FEED Today: <?php echo date("D, d-M-Y H:i:s")?></
> title>

Needs semicolon at the end of the PHP statement.

> <link>http://bulletin.mmu.edu.my/</link>
> <description>MMU RSS FEED</description>
> <ttl>60<ttl>
>

Should be <ttl>60</ttl>

> <?php
>
> //connect to database
> $db = mysql_connect("localhost", "root", "") or die(mysql_error());

VERY BAD idea to connect with "root", especially with no password.
Major security vulnerability.

> mysql_select_db("bulletin", $db) or die(mysql_error());
>
> $day = date("Y-n-j");
>
> //select queries
> $sql = "SELECT * FROM `bul_data` WHERE `DATE` LIKE '{$day}%' ORDER by
> `DEPARTMENT`";
> echo "sql=".$sql;
>
> $res = mysql_query($sql) or die(mysql_error());
>
> if(mysql_num_rows($res)>0)
> {
>
> while($row=mysql_fetch_assoc($res))
> {
> $date = $row['DATE'];
> $title = $row['TITLE'];
> $department = $row['DEPARTMENT'];
> $link = $row['LINK'];
>
> //output to browser
>
> echo "<item>";
> echo "<title>$title</title>";
> echo "<category>$department</category>";
> echo "<link><a href=\"$link\">$link</a></link>";
> echo "</item>";
>
>
> }
>
> echo "</table>";
>
> }
>
> ?>
>
> </channel>
> </rss>
> </body>
> </html>
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация