Page 1 of 1

problem with arrays

Posted: Tue Sep 06, 2005 1:53 am
by itsmani1
value of

$ans = 1;

Code: Select all

$b[$ans] = $GameId;  
    
//what i think is it shoud  replace $b[1] 's old value with value of $GameId.

for($i=0; $i<4; $i++)
{
	$SkyRes1 = mysql_query("SELECT GameAnswer FROM `games` WHERE GameId = '$b[$i]'") or die(mysql_error());
	$Num1 = mysql_num_rows($SkyRes1);
	if($Num1 > 0)
	{
		if($SkyRow1 = mysql_fetch_object($SkyRes1))
		{
			$GameAnswer1 = $SkyRow1 -> GameAnswer;
		}
	}
}
but when i printed my query it gave me result some thing like this
Result

SELECT GameAnswer FROM `games` WHERE GameId = '7'
SELECT GameAnswer FROM `games` WHERE GameId = '6'
SELECT GameAnswer FROM `games` WHERE GameId = '3'
SELECT GameAnswer FROM `games` WHERE GameId = '2'

Thanx.
Mannan.

Posted: Tue Sep 06, 2005 2:22 am
by itsmani1
okies problem is solved.

actually problem was this that some times when "$GameId" comes with value >3 it was creating problem as array starts indexing from 0 and in this way it puts 4 value on 3rd location. this was the main probelem tht created issues for me.

...........
Mannan. :!: