Welcome to Dream.In.Code
Become a PHP Expert!

Join 149,991 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,330 people online right now. Registration is fast and FREE... Join Now!




Maximum execution time

 
Reply to this topicStart new topic

Maximum execution time

TyForHelping
19 Nov, 2006 - 02:39 AM
Post #1

New D.I.C Head
*

Joined: 8 Nov, 2006
Posts: 11


My Contributions
CODE

<center><b>Rank top 10</b></center>
<br>
<br>
<table align="center" border="1" color="white">
<tr bgcolor="#1B293D">
<td width="40"><font color="white">Position</td>
<td width="250"><font color="white">Name</td>
<td width="40"><font color="white">Rank</td>
</tr>

<?
include("dbconnect.php");

$sql = mysql_query("SELECT uname,rank,exp FROM members ORDER BY exp DESC LIMIT 10");
$i = 0;

while ($i < $sql){
    while ($status=mysql_fetch_array($sql)){
            $rank = $i+1;
        
        echo "<tr bgcolor='#34547f'>";
        echo "<td width='40'><font color='white'> ".$rank." </td>";
        echo "<td width='130'><font color='white'><a href='index.php?action=charlookup.php&uname=".$status['uname']."'>".$status['uname']."<a></td>";
        echo "<td width='80'><font color='white'> ".$status['rank']." </td>";
        echo "</tr>";

        ++$i;
    }
}

mysql_close();
?>

</table>

CODE

Fatal error: Maximum execution time of 30 seconds exceeded in /usr/home/100219/public_html/php/highscore.php on line 18

When opening the page it waits 30 seconds and then it displays the error and the highscores, so the highscore works fine, but it takes 30 seconds to load before displaying highscores

This post has been edited by TyForHelping: 19 Nov, 2006 - 02:46 AM
User is offlineProfile CardPM
+Quote Post

MathewS
RE: Maximum Execution Time
19 Nov, 2006 - 07:20 AM
Post #2

D.I.C Regular
***

Joined: 14 May, 2002
Posts: 252



Thanked: 1 times
Dream Kudos: 1
My Contributions
why do you have two loops?

try just using
CODE

    while ($status=mysql_fetch_array($sql)){
            $rank = $i+1;
        
        echo "<tr bgcolor='#34547f'>";
        echo "<td width='40'><font color='white'> ".$rank." </td>";
        echo "<td width='130'><font color='white'><a href='index.php?action=charlookup.php&uname=".$status['uname']."'>".$status['uname']."<a></td>";
        echo "<td width='80'><font color='white'> ".$status['rank']." </td>";
        echo "</tr>";

        ++$i;
    }


or make it even easier and get rid of $i and just use this

CODE

    while ($status=mysql_fetch_array($sql)){
            $rank++;
        
        echo "<tr bgcolor='#34547f'>";
        echo "<td width='40'><font color='white'> ".$rank." </td>";
        echo "<td width='130'><font color='white'><a href='index.php?action=charlookup.php&uname=".$status['uname']."'>".$status['uname']."<a></td>";
        echo "<td width='80'><font color='white'> ".$status['rank']." </td>";
        echo "</tr>";
    }


This post has been edited by MathewS: 19 Nov, 2006 - 07:22 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 08:05PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month