Hello.
I have the following code:
<?
header("Content-type: text/xml");
include("db_connex_file_generic_fake.php");
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$query = "SELECT newsID, news_headline, news_date, REPLACE(news_headline, ' ', '-') AS news_headline_dashed FROM news ORDER BY news_date DESC LIMIT 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$file= fopen('ticker_items.xml' , 'w');
$xml_output = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
$xml_output = "<ticker>\n";
$xml_output .= "<tickerstyle pause=\"false\" timeout=\"5\" border=\"0px\" bordercolor=\"#ffffff\" background=\"#ffffff\" width=\350px\" height=\"11px\"/>\n";
$xml_output .= "<tickerlinkstyle>\n";
$xml_output .= "<mouseout font=\"Tahoma, Verdana, Arial, sans-serif\" color=\"#666666\" decoration=\"underline\" size=\"11px\"/>\n";
$xml_output .= "<mouseover font=\"Tahoma, Verdana, Arial, sans-serif\" color=\"#000000\" decoration=\"none\" size=\"11px\"/>\n";
$xml_output .= "</tickerlinkstyle>\n";
for ($x = 0; $x < mysql_num_rows($result) ; $x++){
$row = mysql_fetch_assoc($result);
$xml_output .= "<tickeritem URL=\"http://www.mysite.com/news/" . $row['newsID'] . "/" . $row['news_headline_dashed'] . ".html\">" . $row['news_headline'] . "</tickeritem>\n";
}
$xml_output .= "</ticker>";
fputs($file, $xml_output);
fclose($file);
?>
When I go to the page to view it, I get this error:
Invalid at the top level of the document. Error processing resource 'http://www.crewfans.com/xml_get_news.php'. Line 1, Po...
Error in query: SELECT newsID, news_headline, news_date, REPLACE(news_headline, ' ', '-') AS news_headline_dashed, FROM news...
What did I do wrong?