Jump to content

Embed php in XML file


RTS

Recommended Posts

I am trying to make a live bookmark that retrieves the latest blog entries in my mysql database. my question is, how do I do it? this is my code right now
[code]<?xml version="1.0" encoding="UTF-8"?>
<rss  version="2.0">
    <channel>
        <title>Test Blog</title>
        <description>The most recent gossip in a live bookmark!</description>
        <link>http://www.test.com/</link>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <lastBuildDate>Thu, 02 Nov 2006 19:54:18 -0800</lastBuildDate>
        <pubDate>Thu, 02 Nov 2006 19:53:55 -0800</pubDate>
        <generator>FeedForAll Mac v2.0 (2.0.0.4) unlicensed version; http://www.FeedForAll.com/</generator>
        <item>
            <title><?php
$con = mysql_connect("localhost","ZackBabtkis","");
$user = $_SESSION['username'];
if(!$con) {die("could not connect");}
mysql_select_db("test",$con)or die("could not connect to database");
$query = mysql_query("SELECT text FROM blogn WHERE id=1");
while ($row = mysql_fetch_array ($query));
echo $row['text'];
?></title>
            <link>http://www.test.com/events.php?id=1</link>
            <pubDate>Thu, 02 Nov 2006 19:51:34 -0800</pubDate>
        </item>
    </channel>
</rss>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.