Re: Miscount

From: Date: Fri, 14 Dec 2001 22:52:55 +0000
Subject: Re: Miscount
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77785@lists.php.net to get a copy of this message
I do not know if this will solve your problem but you should enclose each logical query segment with parenthesies... $shot_counts = "SELECT COUNT(*) FROM statistik WHERE (shooter='$shooter_login' && shot_one = '$t') || (shooter='$shooter_login' && shot_two = '$t') || (shooter='$shooter_login' && shot_three = '$t') || (shooter='$shooter_login' && shot_four = '$t') || (shooter='$shooter_login' && shot_five = '$t')"; > Hi guys, > > still seem to have some trouble with this code. I solved the earlier issues, > with your valuable help. But when i echo the results of the query it gives > me the wrong results. I have never encountered a faulty count from mysql > earlier. Are there any issues with the query i should consider? > > $t = 6; > $shot_counts = "SELECT COUNT(*) FROM statistik WHERE > shooter='$shooter_login' && shot_one = '$t' || > shooter='$shooter_login' && > shot_two = '$t' || shooter='$shooter_login' && shot_three = > '$t' || > shooter='$shooter_login' && shot_four = '$t' || > shooter='$shooter_login' && > shot_five = '$t'"; > $results = mysql_query($shot_counts); > $bam = mysql_fetch_array($results); > > # Daniel Alsén | www.mindbash.com # > # d@mindbash.com | +46 704 86 14 92 # > # ICQ: 63006462 | +46 8 694 82 22 # > # PGP: http://www.mindbash.com/pgp/ # > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#77785) next »