0

我在加载此网站时遇到问题 - http://decoded.ro/l2tales。问题是由以下 2 个 PHP 脚本引起的:

<?php
mysql_connect('example.com','XXXXXXX', 'XXXXXXXX') or die(mysql_error());
mysql_select_db('dbname');
$query = mysql_query("SELECT * FROM `smf_topics` WHERE `id_board` = '2' ORDER BY `id_topic` DESC LIMIT 5");
//echo '<span style="color: white;">DARK' . $query . '</span>';
while($row = mysql_fetch_assoc($query))
{
$id_topic = $row['id_topic'];
$query2 = mysql_query("SELECT * FROM `smf_messages` WHERE `id_topic` = $id_topic");
$row2 = mysql_fetch_assoc($query2);

echo '<div class="page-title">';
echo '<a href="http://forum.l2tales.com//index.php?topic=' . $row['id_topic'] . '/" title="' . htmlspecialchars_decode(substr($row2['subject'], 0 ,75)) . '" target="_blank"><h1>' . htmlspecialchars_decode(substr($row2['subject'], 0 ,200)) . '</h1></a>';
echo '<p style="color: #eed883;">';
echo 'Author: ' . $row2['poster_name'];
echo '</p>';
echo '<p>';
echo $row2['body'];
echo '</p>';
echo '</div>';
}
?>

<?php
mysql_connect('example.com','XXXXXXX', 'XXXXXXXX') or die(mysql_error());
mysql_select_db('dbname');
$query = mysql_query("SELECT * FROM `smf_topics` WHERE `id_board` = '4' ORDER BY `id_topic` DESC LIMIT 5");
//echo '<span style="color: white;">DARK' . $query . '</span>';
while($row = mysql_fetch_assoc($query))
{
$id_topic = $row['id_topic'];
$query2 = mysql_query("SELECT * FROM `smf_messages` WHERE `id_topic` = $id_topic");
$row2 = mysql_fetch_assoc($query2);

$count = strlen($row2['subject']);
if($count > '59')
$dots = '...';
else
$dots = '';

echo '<li>';
echo '<a href="http://forum.l2tales.com//index.php?topic=' . $row['id_topic'] . '/" title="' . htmlspecialchars_decode(substr($row2['subject'], 0 ,75)) . '" target="_blank">';
echo '<span>' . htmlspecialchars_decode(substr($row2['subject'], 0 ,59)) . $dots . '</span>';
echo '<p>';
echo 'Author: ' . $row2['poster_name'];
echo '</p>';
echo '</a>';
echo '</li>';
}
?>

这些 PHP 脚本是从托管在服务器 B 上的 SMF 数据库中获取的(稍后将解释)最新的 5 个主题。

所以我有2台服务器。在服务器 A(decoded.ro/l2tales)上它工作正常,加载对我来说几乎是即时的。在托管论坛的服务器 B 上,网站加载数年。在这里,您可以看到托管在服务器 B 上的网站的地址 - http://l2tales.com/dark(起初您会看到一个空白页面,但网站仍在加载,请等待它完全加载)。

为什么跟论坛在同一个服务器上那么慢,而在不同的服务器上却是即时的?

谢谢

4

0 回答 0