我的网站在此链接中存在问题: -
http://www.3-hail.com/API/news.php
我收到此错误消息: -
第6行第2行的错误:仅在文档开头允许XML声明
当我尝试连接此文件news.php
时 <?php
require_once("config.php");
$result = mysql_query("select * from newsm WHERE news_id='1' ORDER BY id Desc Limit 30");
while ($row = @mysql_fetch_array($result)) {
$title[] = $row['caption'];
$Image[] = $row['ext'];
$postID[] = $row['id'];
$Textnews[] = $row['text'];
$containing[] = $row['text'];
$post_date[] = $row['date'];
}
function sublen($text,$of,$to){
if(strlen($text) > $to){
echo substr($text,$of,$to)." ...";
}else{
echo $text;
}
}
$count = count($title);
for ( $e = 0; $e <= $count-1; $e += 1) {
}
echo '<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>صحيفة عيون حائل</title>
<link>http://3-hail.com/</link>
<description>صحيفة عيون حائل</description>';
for ( $i = 0; $i <= $count-1; $i += 1) {
$word = array(" ","[/CENTER]","[/JUSTIFY]","[CENTER]","[JUSTIFY]","[email]","[/email]","[/url]","[url]","[B]","[/B]","[IMG]","[/IMG]");
$text = $containing[$i];
$replace = "";
$containingNews = str_replace($word,$replace,$text);
echo '<item>
<title>'.$title[$i] = iconv("windows-1256", "UTF-8", $title[$i]).'</title>
<description>'.$substring = mb_substr($Textnews[$i] = iconv("windows-1256", "UTF-8", $Textnews[$i]),0,100,"utf-8").'...</description>
<containing>'.$containingNews = htmlspecialchars(strip_tags(iconv("windows-1256", "UTF-8", $containingNews))).'</containing>
<link>http://3-hail.com/news.php?action=show&id=' . $postID[$i] . '</link>
<enclosure>http://3-hail.com/contents/newsm/' . $postID[$i] . '.' . $Image[$i] . '</enclosure>
<enclosurem>http://3-hail.com/contents/newsm/' . $postID[$i] . '.' . $Image[$i] . '</enclosurem>
<bubdate>' . date('H:i d-m-Y', $post_date[$i] ) . '</bubdate>
</item>';
}
echo'</channel>
</rss>';
?>