php - 在动态站点地图 php xml xmlParseEntityRef 中显示错误:没有名称
问题描述
我正在制作动态站点地图,但出现以下错误,我知道答案已经存在但我不明白,请指导
error on line 68 at column 69: xmlParseEntityRef: no name
这是代码有什么问题
<?php
require_once("config.php");
$status=1;
$sql1 = "SELECT * FROM admitcard WHERE status=? ORDER BY id DESC";
$stmt1 = $mysqli->prepare($sql1);
$stmt1->bind_param("s", $status);
$stmt1->execute();
$admit_result = $stmt1->get_result();
?>
<?php
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>daily</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>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
}
echo '</urlset>' . PHP_EOL;
?>
这个运行得很完美,但是上面的脚本中显示了错误,认为它们都非常相似
while($row3=mysqli_fetch_array($schlar_result)){
echo '<url>' . PHP_EOL;
echo '<loc>'.'https://loclhost:8080/Site/other/'.$row3["id"].'/'. str_replace(' ','-',trim($row3['pagename_schlr'])).'</loc>' . PHP_EOL;
echo '<lastmod>'.date('c',time()).'</lastmod>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
}
解决方案
推荐阅读
- javascript - 如何使用 Node.js 将文件路径保存到我的数据库?
- vue.js - Vue meta i18n 变量名显示而不是值
- c# - 无法弄清楚 Expression.Call for Guid.Equals 进入谓词的语法
- c# - C# 中的 Excel 导入 - 缺少列错误
- python-3.x - 如何从 python3 中的字符串打印十进制数?
- http - 使用 http-server 在本地托管/服务时如何设置自定义 HTTP 标头?
- excel - Excel to DataSet 使用 OLEDB 在 .NET Core 和 .NET Framework 之间工作方式不同
- php - 提取 USPS 运输跟踪号的第一个实例
- tableau-api - Tableau 中的一个绘图中的三个数据集
- html - 尽管有 `line-height: 1` 和 `overflow: hidden`,仍保持悬挂字符可见