Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 1, 2026.

30s Timeout

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
Watch

Barrucadu

Established Member
Impact
64
My script keeps causing a timeout by taking longer than 30 seconds, basicly it should access the database and get all the games (which is about 14) and list all the ones with a rating above 4 (which is 1) as you can see here its all goes strange, heres the code:

PHP:
while($i < $num){
	$totalrat = mysql_result($results,$i,"totalrat");
	$rats = mysql_result($results,$i,"rats");
	$name = mysql_result($results,$i,"name1");
	if($totalrat/$rats > 4){
		echo '<a href = "Games/'.$name.'.php"><img src="Games/'.$name.'.gif" width="50" height="50" border="0"></a></br>';
	}
}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
at the top of your script:

PHP:
set_time_limit(0);


It will not timeout.... lol

Rep plz, if this helps.
 
0
•••
problem with that is it could go on forever, your best bet would be to find the cause of the problem.

at a quick glance it seems that you are never increasing $i so $i < $num argument is never met, at the end of the while loop do the following:-

$i++;
 
1
•••
filth said:
problem with that is it could go on forever, your best bet would be to find the cause of the problem.

at a quick glance it seems that you are never increasing $i so $i < $num argument is never met, at the end of the while loop do the following:-

$i++;


I did notice that, but i wasnt sure if that its supposed to do that.... Should have said.

It can be done with a for loop too? I like those better than a while loop.
 
0
•••
filth you now have some more rep, axailant i got this message
vBulliten said:
You must spread some Reputation around before giving it to axilant again.
 
0
•••
$i++;
 
0
•••
now I have a different error, its supposed to put the pictures in rows of 5 but it says cannot jump to row 1 for some reason.

PHP:
$num = mysql_num_rows($results);
$i = 1;
$i2 = 0;

echo 'Popular Games:<br><br>';

while($i2 < $num){
	while($i < 6){
		$totalrat = mysql_result($results,$i2,"totalrat");
		$rats = mysql_result($results,$i2,"rats");
		$name = mysql_result($results,$i2,"name1");
		if($totalrat/$rats > 3.5){
			echo '<a href = "Games/'.$name.'.php"><img src="Games/'.$name.'.gif" width="50" height="50" border="0"></a>';
		}
		$i++;
		$i2 ++;
	}
	if($i == 5){
		echo "<br>";
		$i = 1;
	}
}
 
0
•••
axilant said:
I did notice that, but i wasnt sure if that its supposed to do that.... Should have said.

It can be done with a for loop too? I like those better than a while loop.

anytime a while loop is comparing a number with another number 1 of the numbers MUST be incremented otherwise you end up with a continuous loop.

Mikor said:
now I have a different error, its supposed to put the pictures in rows of 5 but it says cannot jump to row 1 for some reason.

from the code you have posted I cannot see why it would output that, have you got any code you are not showing us?

Also unless I am interpreting the code incorrectly if($i == 5) should actually be:-

if($i == 6)
 
Last edited:
0
•••
ah well, cant find the error, maybe it would be best to re-write that script,

what I want is a script that will connect to the database and get the top 10 games in a table field, in the field next to that the bottom 10 games and in the row under that other games and unrated games, all games should be in order of rating, the fields in the database are as follows:

name1 - name of the game (also the HTM file and GIF file for the game, eg name1.gif and name1.php)
totalrat - the total rating of that game (not average)
rats - the number of ratings of that game
itemtype - the type of the file (just use 'game', i can modify the script for videos and downloads)

using this data you can find out some info about the game in question,
Games/[Name1].gif is the image of the game (i want this to show up in the table)
Games/[Name1].php is the URL of the game
totalrat/rats is the average rating

here is a screenshot of what i want to happen:

http://yarrt.com/scriptshot.gif
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back