Database loading problems

71 Views Asked by At

I have an issue with the loading of this website - http://decoded.ro/l2tales. The problem is caused by these 2 PHP scripts:

<?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>';
}
?>

These PHP scrips are fetching from a SMF database on hosted on server B (will explain later) latest 5 topics.

So i have 2 servers. On server A (which is decoded.ro/l2tales) it works fine, is loading is almost instant for me. On server B, where the forum is hosted, the website loads in years. Here you can see a adress for the website hosted on server B - http://l2tales.com/dark (At first you will see a blank page but the website is still loading, just wait until it loads completly).

Why on the same server with the forum is so slow but on a different server is instant?

Thanks

0

There are 0 best solutions below