Lamez Posted March 2, 2008 Share Posted March 2, 2008 This is code is not processing properly What it is suppose to do is: 1.check to see if the row r1 is equal to 0 if so, then it will check to see if the user made the correct pick with the winner, if so add points, then to does the same with the next selections. 2.Then it checks to see if the processed variables where equal to emp or not, if so replaces the one with a 0 in the DB, to tell it, it can be processed again. Well it does not anything in the DB at all, nothing is updating. here is the code: <?php include ("../../../style/include/session.php"); function updateTb($tb, $row){ $q = "UPDATE `$tb` SET `$row` = '1'"; mysql_query($q); } function checkVar($var, $num){ if ($var === ("emp")){ $q = "UPDATE `rnd1_check` SET `r".$num."` = '0' WHERE `id` = '1'"; mysql_query($q); } } $table = "rnd1_check"; $qu = "SELECT * FROM `$table`"; $re = mysql_query($qu); $ck = mysql_fetch_array($re); $result=mysql_query('SELECT * FROM userpoints') or die(mysql_error()); while($row=mysql_fetch_array($result)){ $user=$row['username']; /*Pull Winners for Round 1*/ $q = mysql_query("Select * from `rnd1_win`"); $win=mysql_fetch_array($q); /*Pull User Picks for Round 1*/ $q = mysql_query("Select * from `rnd1` Where `username` = '$user'"); $pick=mysql_fetch_array($q); /*Pull Point Values for Round 1*/ $q = mysql_query("Select rnd1 from `points`"); $point=mysql_fetch_array($q); $value = $point['rnd1']; /*Pull User Points for Round 1*/ $q = mysql_query("Select `username`, `total`, `rnd1` from `userpoints` Where `username` = '$user'"); $usrpoint=mysql_fetch_array($q); $total = $usrpoint['total']; $rnd1 = $usrpoint['rnd1']; if ($ck['r1'] == ("0")){ if ( $win['1'] == $pick['a1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r1); } } if ($ck['r2'] == ("0")){ if ( $win['2'] == $pick['a2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r2); } } if ($ck['r3'] == ("0")){ if ( $win['3'] == $pick['a3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r3); } } if ($ck['r4'] == ("0")){ if ( $win['4'] == $pick['a4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r4); } } if ($ck['r5'] == ("0")){ if ( $win['5'] == $pick['a5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r5); } } if ($ck['r6'] == ("0")){ if ( $win['6'] == $pick['a6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r6); } } if ($ck['r7'] == ("0")){ if ( $win['7'] == $pick['a7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r7); } } if ($ck['r8'] == ("0")){ if ( $win['8'] == $pick['a8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r8); } } if ($ck['r9'] == ("0")){ if ( $win['9'] == $pick['b1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r9); } } if ($ck['r10'] == ("0")){ if ( $win['10'] == $pick['b2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r10); } } if ($ck['r11'] == ("0")){ if ( $win['11'] == $pick['b3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r11); } } if ($ck['r12'] == ("0")){ if ( $win['12'] == $pick['b4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r12); } } if ($ck['r13'] == ("0")){ if ( $win['13'] == $pick['b5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r13); } } if ($ck['r14'] == ("0")){ if ( $win['14'] == $pick['b6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r14); } } if ($ck['r15'] == ("0")){ if ( $win['15'] == $pick['b7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r15); } } if ($ck['r16'] == ("0")){ if ( $win['16'] == $pick['b8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r16); } } if ($ck['r17'] == ("0")){ if ( $win['17'] == $pick['c1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r17); } } if ($ck['r18'] == ("0")){ if ( $win['18'] == $pick['c2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r18); } } if ($ck['r19'] == ("0")){ if ( $win['19'] == $pick['c3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r19); } } if ($ck['r20'] == ("0")){ if ( $win['20'] == $pick['c4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r20); } } if ($ck['r21'] == ("0")){ if ( $win['21'] == $pick['c5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r21); } } if ($ck['r22'] == ("0")){ if ( $win['22'] == $pick['c6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r22); } } if ($ck['r23'] == ("0")){ if ( $win['23'] == $pick['c7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r23); } } if ($ck['r24'] == ("0")){ if ( $win['24'] == $pick['c8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r24); } } if ($ck['r25'] == ("0")){ if ( $win['25'] == $pick['d1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r25); } } if ($ck['r26'] == ("0")){ if ( $win['26'] == $pick['d2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r26); } } if ($ck['r27'] == ("0")){ if ( $win['27'] == $pick['d3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r27); } } if ($ck['r28'] == ("0")){ if ( $win['28'] == $pick['d4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r2); } } if ($ck['r29'] == ("0")){ if ( $win['29'] == $pick['d5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r29); } } if ($ck['r30'] == ("0")){ if ( $win['30'] == $pick['d6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r30); } } if ($ck['r31'] == ("0")){ if ( $win['31'] == $pick['d7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r31); } } if ($ck['r32'] == ("0")){ if ( $win['32'] == $pick['d8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); updateTb($table, r32); } } checkVar($a1, 1); checkVar($a2, 2); checkVar($a3, 3); checkVar($a4, 4); checkVar($a5, 5); checkVar($a6, 6); checkVar($a7, 7); checkVar($a8, ; checkVar($b1, 9); checkVar($b2, 10); checkVar($b3, 11); checkVar($b4, 12); checkVar($b5, 13); checkVar($b6, 14); checkVar($b7, 15); checkVar($b8, 16); checkVar($c1, 17); checkVar($c2, 18); checkVar($c3, 19); checkVar($c4, 20); checkVar($c5, 21); checkVar($c6, 22); checkVar($c7, 23); checkVar($c8, 24); checkVar($d1, 25); checkVar($d2, 26); checkVar($d3, 27); checkVar($d4, 28); checkVar($d5, 29); checkVar($d6, 30); checkVar($d7, 31); checkVar($d8, 32); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/94035-i-just-need-some-help/ Share on other sites More sharing options...
pocobueno1388 Posted March 2, 2008 Share Posted March 2, 2008 Put die()'s at the end of ALL your queries. or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/94035-i-just-need-some-help/#findComment-481733 Share on other sites More sharing options...
Lamez Posted March 2, 2008 Author Share Posted March 2, 2008 it updates the winner, but does not put a 1 in the check table (r1, r2, etc) that page I posted was included from this page, maybe this page is the problem: <?php include ("../../../style/include/session.php"); include ("../../../style/include/cons/head_3.php"); if($session->isAdmin()){ $a1 = $_POST['a1']; $a2 = $_POST['a8']; $a3 = $_POST['a5']; $a4 = $_POST['a4']; $a5 = $_POST['a6']; $a6 = $_POST['a3']; $a7 = $_POST['a7']; $a8 = $_POST['a2']; $b9 = $_POST['b1']; $b10 = $_POST['b8']; $b11 = $_POST['b5']; $b12 = $_POST['b4']; $b13 = $_POST['b6']; $b14 = $_POST['b3']; $b15 = $_POST['b7']; $b16 = $_POST['b2']; $c17 = $_POST['c1']; $c18 = $_POST['c8']; $c19 = $_POST['c5']; $c20 = $_POST['c4']; $c21 = $_POST['c6']; $c22 = $_POST['c3']; $c23 = $_POST['c7']; $c24 = $_POST['c2']; $d25 = $_POST['d1']; $d26 = $_POST['d8']; $d27 = $_POST['d5']; $d28 = $_POST['d4']; $d29 = $_POST['d6']; $d30 = $_POST['d3']; $d31 = $_POST['d7']; $d32 = $_POST['d2']; $q = "UPDATE `rnd1_win` SET `1` = '$a1', `2` = '$a2', `3` = '$a3', `4` = '$a4', `5` = '$a5', `6` = '$a6', `7` = '$a7', `8` = '$a8', `9` = '$b9', `10` = '$b10', `11` = '$b11', `12` = '$b12', `13` = '$b13', `14` = '$b14', `15` = '$b15', `16` = '$b16', `17` = '$c17', `18` = '$c18', `19` = '$c19', `20` = '$c20', `21` = '$c21', `22` = '$c22', `23` = '$c23', `24` = '$c24', `25` = '$d25', `26` = '$d26', `27` = '$d27', `28` = '$d28', `29` = '$d29', `30` = '$d30', `31` = '$d31', `32` = '$d32' WHERE `id` = '1'"; mysql_query($q) or die(mysql_error()); include ("pnt_1.php"); print '<div class="box"><h2>Winners Updated</h2>'; print '<p>Winners Updated for Round 2<br><br>'; print '<a href="slcwin_1.php">Round 2</a></p>'; print '</div>'; }else{ header("Location: ../../../index.php"); } include ("../../../style/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/94035-i-just-need-some-help/#findComment-481759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.