title: Database loading problems
body: <p>I have an issue with the loading of this website - <a href="http://decoded.ro/l2tales" rel="nofollow">http://decoded.ro/l2tales</a>. The problem is caused by these 2 PHP scripts:</p>
  
  <pre><code>&lt;?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 '&lt;span style="color: white;"&gt;DARK' . $query . '&lt;/span&gt;';
  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 '&lt;div class="page-title"&gt;';
  echo '&lt;a href="http://forum.l2tales.com//index.php?topic=' . $row['id_topic'] . '/" title="' . htmlspecialchars_decode(substr($row2['subject'], 0 ,75)) . '" target="_blank"&gt;&lt;h1&gt;' . htmlspecialchars_decode(substr($row2['subject'], 0 ,200)) . '&lt;/h1&gt;&lt;/a&gt;';
  echo '&lt;p style="color: #eed883;"&gt;';
  echo 'Author: ' . $row2['poster_name'];
  echo '&lt;/p&gt;';
  echo '&lt;p&gt;';
  echo $row2['body'];
  echo '&lt;/p&gt;';
  echo '&lt;/div&gt;';
  }
  ?&gt;
  
  &lt;?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 '&lt;span style="color: white;"&gt;DARK' . $query . '&lt;/span&gt;';
  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 &gt; '59')
  $dots = '...';
  else
  $dots = '';
  
  echo '&lt;li&gt;';
  echo '&lt;a href="http://forum.l2tales.com//index.php?topic=' . $row['id_topic'] . '/" title="' . htmlspecialchars_decode(substr($row2['subject'], 0 ,75)) . '" target="_blank"&gt;';
  echo '&lt;span&gt;' . htmlspecialchars_decode(substr($row2['subject'], 0 ,59)) . $dots . '&lt;/span&gt;';
  echo '&lt;p&gt;';
  echo 'Author: ' . $row2['poster_name'];
  echo '&lt;/p&gt;';
  echo '&lt;/a&gt;';
  echo '&lt;/li&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p>These PHP scrips are fetching from a SMF database on hosted on server B (will explain later) latest 5 topics.</p>
  
  <p>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 - <a href="http://l2tales.com/dark" rel="nofollow">http://l2tales.com/dark</a> (At first you will see a blank page but the website is still loading, just wait until it loads completly).</p>
  
  <p>Why on the same server with the forum is so slow but on a different server is instant?</p>
  
  <p>Thanks</p>