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
https://forums.phpfreaks.com/topic/26020-embed-php-in-xml-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.