Jump to content

[SOLVED] XML problem


scadran

Recommended Posts

guys,

here is the simple code i used to create a RSS

 

but this error appears

 

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Journalness\rss.php on line 11

 

here is the code:

<?php

$connection = mysql_connect("localhost", "root", "123");
mysql_select_db("emu", $connection);

$select = "SELECT `id`, `title`, `entry_text`, `date` FROM `emu_entries` ORDER BY `id` DESC LIMIT 5";
$query = mysql_query($select) or die(mysql_error());

$file = fopen("rss.xml", "w")

fwrite($file, "<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>The Shadow Fox Feed</title>
<link>http://www.shadow-fox.net</link>
<description>Feed Description</description>
<language>en-us</language>");

while($array = mysql_fetch_array($query)){
extract($array);

$content = htmlentities($entry_text);

fwrite($file, "<item>
<title>$title</title>
<link>http://localhost/Journalness/past.php?id=$id</link>
<description>$content</description>
</item>");
}
//end of while loop
fwrite($file, "</channel></rss>");
fclose($file);
?>

 

I am sure there s no problem with my database connection and the file previlage.

 

Regards

Mohsen

Link to comment
https://forums.phpfreaks.com/topic/48078-solved-xml-problem/
Share on other sites

Sorry for the misunderstanding with the <?php tags. I don't know why I placed them.

 

<?php

$connection = mysql_connect("localhost", "root", "123");
mysql_select_db("emu", $connection);

$select = "SELECT `id`, `title`, `entry_text`, `date` FROM `emu_entries` ORDER BY `id` DESC LIMIT 5";
$query = mysql_query($select) or die(mysql_error());

$file = fopen("rss.xml", "w")

fwrite($file, "<?xml version=\"1.0\"?>
<rss version=\"2.0\">
<channel>
<title>The Shadow Fox Feed</title>
<link>http://www.shadow-fox.net</link>
<description>Feed Description</description>
<language>en-us</language>");

while($array = mysql_fetch_array($query)){
extract($array);

$content = htmlentities($entry_text);

fwrite($file, "<item>
<title>$title</title>
<link>http://localhost/Journalness/past.php?id=$id</link>
<description>$content</description>
</item>");
}
//end of while loop
fwrite($file, "</channel></rss>");
fclose($file);
?>

 

I'm pretty sure this will work.

Link to comment
https://forums.phpfreaks.com/topic/48078-solved-xml-problem/#findComment-234976
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.