数据库加载问题

时间:2014-08-28 15:33:03

标签: php database smf-forum

我在加载此网站时遇到问题 - http://decoded.ro/l2tales。问题是由这两个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(解码.ro / lltales)它工作正常,加载对我来说几乎是即时的。在托管论坛的服务器B上,网站加载数年。 在这里,您可以看到服务器B上托管的网站的地址 - http://l2tales.com/dark(首先您会看到一个空白页但网站仍在加载,只需等到它完全加载)。

为什么在与论坛相同的服务器上这么慢但在不同的服务器上是即时的?

由于

0 个答案:

没有答案