我在 php.ini 中生成了一个 XML 文件。这个文件在我的本地主机中完美地生成了一个 xml 输出,同时当我将它上传到我的服务器时它失败了。
错误屏幕
这是代码。
<?php
include_once("database/db.php");
$sqlNews = "SELECT * FROM news";
$runSqlNews = mysql_query($sqlNews);
while ($rowSqlNews = mysql_fetch_array($runSqlNews))
$arrSqlNews[] = $rowSqlNews;
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<xml>';
for($i=0;$i<count($arrSqlNews);$i++)
{
echo "<news>";
echo "<newsId>".$arrSqlNews[$i][id]."</newsId>";
echo "<newsAuthor>".$arrSqlNews[$i][news_author]."</newsAuthor>";
echo "<description>".$arrSqlNews[$i][news_description]."</description>";
echo "<newsText> <![CDATA[".$arrSqlNews[$i][news_text]. "]]></newsText>";
echo "<plainNewsDescription>".$arrSqlNews[$i][plain_news_description]."</plainNewsDescription>";
echo "<plainNewsTitle>".$arrSqlNews[$i][plain_news_title]."</plainNewsTitle>";
echo "<newsUrl> <![CDATA[". $arrSqlNews[$i][news_url]. "]]></newsUrl>";
echo "<newsCategory> <![CDATA[". $arrSqlNews[$i][category]. "]]></newsCategory>";
echo "<image>http://metroplots.com/images/members/".$arrSqlNews[$i][news_image]."</image>";
echo "<createdOn>".$arrSqlNews[$i][created_on]."</createdOn>";
echo "</news>";
}
echo '</xml>';
?>
更改后的新 xml 文件
<?php
ini_set('error_reporting', E_ALL);
include_once("database/db.php");
$dbConn = new mysqli($dbHost, $dbUserName, $dbUserPasswrd, $database);;
$sqlNews = "SELECT id, news_author,news_description,
news_text, news_url, category, news_image, created_on
FROM news";
$stmt = $dbConn->prepare($sqlNews);
$stmt->execute();
$stmt->bind_result($id, $newsAuthor, $newsDescription, $newsText, $newsUrl, $Category, $newsImage, $createdOn);
header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo '<xml>';
echo "<news>";
while($stmt->fetch())
{
echo "<newsId>".$id."</newsId>";
echo "<newsAuthor>".$newsAuthor."</newsAuthor>";
echo "<description>".$newsDescription."</description>";
echo "<newsText> <![CDATA[".$newsText. "]]></newsText>";
echo "<newsUrl> <![CDATA[". $newsUrl. "]]></newsUrl>";
echo "<newsCategory> <![CDATA[". $Category. "]]></newsCategory>";
echo "<image>http://metroplots.com/images/members/".$newsImage."</image>";
echo "<createdOn>".$createdOn."</createdOn>";
}
echo "</news>";
echo '</xml>';
$stmt->close();
$dbConn->close();
?>
请让我知道我哪里出错了。提前致谢 !!!