Re: UPDATE problem

From: Date: Mon, 20 Aug 2001 22:47:32 +0000
Subject: Re: UPDATE problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63578@lists.php.net to get a copy of this message
> I have created a predictionscompetition and some code counts te total score of > a match of a person. > On the screen it workes, but in de database it goes wrong. Each person gets > the total of the last person. There must be something wrong with the update > statement. > I hope someone can help me. > > Cheers, > Martin. > > $number = MYSQL_NUMROWS($result); > $i = 0; > WHILE ($i < $number): > $naam = mysql_result($result,$i,"naam"); > $uit_gr = mysql_result($result,$i,"uit_gr"); > $uit_te = mysql_result($result,$i,"uit_te"); > $ru_gr = mysql_result($result,$i,"ru_gr"); > $ru_te = mysql_result($result,$i,"ru_te"); > $minuut = mysql_result($result,$i,"minuut"); > $toto = mysql_result($result,$i,"toto"); > > /* Count everything*/ > > $t01 = $u1+$r1+$b1+$m1+$t1; > $sqlb = "UPDATE voorspelling1 SET totaal='$t01' WHERE id_voorspelling = > '$id_voorspelling'"; > $resultb = mysql_query($sqlb); > PRINT "$naam $uit_gr $uit_te $u1 $r1 $b1 $m1 $t1 $t01<BR>"; > PRINT "$t1<BR>"; > $i++; > ENDWHILE; So $t01 is PRINTed correctly but is incorrect in the database? Check mysql_affected_rows() after the query is run to see if any changes were made to the databse. The only potential problems I see off the top of my head are the single quotes around $t01 and $voorspelling in the query. If either of those are numeric values, then you must omit the single quotes. Hope this helps...

« previous php.general (#63578) next »