我正在制作一個動態網站地圖,并得到這個錯誤,但我不明白問題出在哪里。請指導一下。我知道有些答案已經在那里了
。 error on line 87 at column 64: xmlParseEntityRef:沒有名字
下面是代碼
require_once("configure/config.php") 。
$status=1;
$sql1 = "SELECT * FROM admitcard WHERE status=? ORDER BY id DESC"。
$stmt1 = $mysqli-> prepare($sql1)。
$stmt1->bind_param("s"/span>, $status)。
$stmt1-> execute();
$admit_result = $stmt1-> get_result()。
header("Content-Type: application/xml; charset=utf-8") 。
echo '<!--?xml version="1.0" encoding="UTF-8"?--> '.PHP_EOL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL。
echo '<url> ' . PHP_EOL。
echo '<loc>'.$base_url.'</loc> ' . PHP_EOL。
echo '<changefreq>day</changefreq>' . PHP_EOL。
echo '</url> ' . PHP_EOL。
while($row2=mysqli_fetch_array($admit_result)){
echo '<url> ' . PHP_EOL。
echo '<loc>'。 'localhost:8080/mysite/admitcard/'.$row2["id"] 。 '/'。 str_replace(' ','-',trim($row2['pagename_admit']). '</loc>' . PHP_EOL。
echo '<lastmod>'.date('c',time()).'</lastmod> ' 。PHP_EOL。
echo '<changefreq>day</changefreq>' 。PHP_EOL。
echo '</url> ' . PHP_EOL;
}
echo '</urlset> ' . PHP_EOL。
.
uj5u.com熱心網友回復:
你需要將&替換為&:
echo '< loc> '. 'localhost:8080/mysite/admitcard/'.$row2["id"].'/'。 str_replace(' ','-',trim(preg_replace('/& (?!#? [a-z0-9] ;)/', '&', $row2['pagename_admit']))。 '</loc>' . PHP_EOL。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/324035.html
標籤:
上一篇:從PandasDataframe和Numpy陣列中基于條件的子集提取
下一篇:用PHP在XML中進行回圈
