Jump to content

String Problem :(


rmail2006

Recommended Posts

Im trying to choose a picture from my website but;

  • it must be random
  • each pic is only allowed to be rated once per day

 

Iv set up the code but for some reason it doesnt always work.

 

if($_GET[id]){

}
else
{
$totNum = mysql_num_rows(mysql_query("SELECT * FROM totties"));
echo $totNum."<br/>";
$totSelect = mysql_fetch_array(mysql_query("SELECT * FROM totties ORDER BY rand() LIMIT 0,1"));
$totCheck = mysql_fetch_array(mysql_query("SELECT * FROM ratings WHERE imgId='$totSelect[tottyId]' AND username='$userUsername'"));
if($totCheck[id]){

	$timeDif = time() - $timeLimit;
	$totCheck2 = mysql_fetch_array(mysql_query("SELECT * FROM ratings WHERE id='$totCheck[id]' AND time > $timeDif"));
	$xCount=1;
	if ($totCheck2[id]){
		while($totCheck2[id]){
			$totSelect = mysql_fetch_array(mysql_query("SELECT * FROM totties ORDER BY rand() LIMIT 0,1"));
			$totCheck = mysql_fetch_array(mysql_query("SELECT * FROM ratings WHERE imgId='$totSelect[tottyId]' AND username='$userUsername'"));
			$totCheck2 = mysql_fetch_array(mysql_query("SELECT * FROM ratings WHERE imgId='$totSelect[id]' AND time > $timeDif"));
			if ($xCount==$totNum * 2){
				echo "Rated All Girls";
				$noGirls='1';
				break;
			}
		$xCount++;
		}
		[color=red][b]$tottyChosen = $totSelect[tottyId];
		echo "Got Girl ID ".$totSelect[tottyId];[/b][/color]


	} else {
	$totDetails = mysql_fetch_array(mysql_query("SELECT * FROM usr_images WHERE id='$totSelect[tottyId]'"));
	echo "Rated But Time ID ".$totCheck[imgId];}
	$tottyChosen = $totCheck[imgId];

}else{
	[color=red][b]echo " No Ratings ID ".$totSelect[tottyId];
	$tottyChosen = $totSelect[tottyId];[/b][/color]
}
}
echo "<br/>".$tottyChosen;

 

 

when it writes 'rated but time id ' and 'No Ratings Id ' it passes the id to the string $tottyChosen. That's Fine

 

But when it randomly chooses another and echos 'Got Girl ID ' it doesnt pass the id to the string even though it prints it on screen.

 

Can anyone help plz :(

Thanks

Link to comment
https://forums.phpfreaks.com/topic/171284-string-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.