Pessoal, boa noite!
Estou tentando fazer um feed RSS e esta apresentando o erro abaixo, alguém já passou por isso?
This page contains the following errors:
error on line 2 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error
Segue código fonte.
<?php header('Content-Type: text/xml'); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?><title>Aliens Abducted Me - Newsfeed</title>
<link>localhost/cap12</link>
<description>Alien abduction reports from around the world courtesy of Owen and his abducted dog Fang.</description>
<language>en-us</language>
<?php
require_once('connectvars.php');
// Connect to the database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// Retrieve the alien sighting data from MySQL
$query = "SELECT abduction_id, first_name, last_name, DATE_FORMAT(when_it_happened,'%a, %d %b %Y %T') AS when_it_happened_rfc, " .
"alien_description, what_they_did FROM aliens_abduction ORDER BY when_it_happened DESC";
$data = mysqli_query($dbc, $query);
// Loop through the array of alien sighting data, formatting it as RSS
while ($row = mysqli_fetch_array($data)) {
// Display each row as an RSS item
echo '';
echo ' ' . $row['first_name'] . ' ' . $row['last_name'] . ' - ' . substr($row['alien_description'], 0, 32) . '...';
echo ' localhost/cap12/index.php?abduction_id=' . $row['abduction_id'] . '';
echo ' ' . $row['when_it_happened_rfc'] . ' ' . date('T') . '';
echo ' ' . $row['what_they_did'] . '';
echo '';
}
?>