Lamez Posted February 26, 2008 Share Posted February 26, 2008 This code I have been working on for weeks have givin me so much trouble. What is is suppose to do is pull the userpicks, the winners, the point values, and the users current points all from the DB. Well it does that just fine, then is checks to see if the winners match the userpicks, and if they do add points to there current point value for that round, and add it to the DB. Well it is not updating the users row in the DB under userpoints I set the default values in the userpoints to all to 0 the structure is: Username | total | rnd1 | rnd2 | rnd3 | rnd4 | rnd5 | champ ---------------------------------------------------------- Lamez | 0 | 0 | 0 | 0 | 0 | 0 | 0 That is the default when a user registers, but the code does not add points to the DB, why? The code is very consistent so once you have seen one IF statment, you have seen 'em all. Code: <?php include("style/include/session.php"); include ("style/include/cons/head.php"); echo '<div class="box">'; $user = "Lamez"; /*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']; /*$result=mysql_query('SELECT * FROM users'); while($row=mysql_fetch_array($result)){ $user=$row['user'];*/ if ( $win['1'] == $pick['a1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['2'] == $pick['a2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['3'] == $pick['a3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['4'] == $pick['a4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['5'] == $pick['a5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['6'] == $pick['a6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['7'] == $pick['a7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['8'] == $pick['a8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['9'] == $pick['b1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['10'] == $pick['b2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['11'] == $pick['b3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['12'] == $pick['b4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['13'] == $pick['b5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['14'] == $pick['b6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['15'] == $pick['b7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['16'] == $pick['b8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['17'] == $pick['c1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['18'] == $pick['c2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['19'] == $pick['c3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['20'] == $pick['c4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['21'] == $pick['c5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['22'] == $pick['c6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['23'] == $pick['c7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['24'] == $pick['c8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['25'] == $pick['d1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['26'] == $pick['d2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['27'] == $pick['d3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['28'] == $pick['d4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['29'] == $pick['d5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['30'] == $pick['d6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['31'] == $pick['d7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } if ( $win['32'] == $pick['d8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'"); } //} //End Loop print '</div>'; include ("style/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/ Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 bump for the night. Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476693 Share on other sites More sharing options...
Northern Flame Posted February 26, 2008 Share Posted February 26, 2008 at the end of each of your mysql_query add or die(mysql_error()) to see if any errors get reported back, so it should look like this: mysql_query("UPDATE `userpoints` SET `total`='$total', `1`='$rnd1' WHERE `username`='$user'")or die(mysql_error()); add that to all the queries and let me know if any errors get reported back. Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476710 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 This is why you do not program late at night. I forgot I change the field name from 1 to rnd1, lol thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476721 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 alright I revised my code for a loop and I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mounted-storage/home48c/sub007/sc33591-LWQU/lamezz.info/pnt.php on line 6 here is my new code: <?php include("style/include/session.php"); include ("style/include/cons/head.php"); echo '<div class="box">'; $result=mysql_query('SELECT * FROM userspoints'); while($row=mysql_fetch_array($result)){ $user=$row['user']; /*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 ( $win['1'] == $pick['a1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['2'] == $pick['a2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['3'] == $pick['a3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['4'] == $pick['a4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['5'] == $pick['a5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['6'] == $pick['a6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['7'] == $pick['a7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['8'] == $pick['a8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['9'] == $pick['b1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['10'] == $pick['b2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['11'] == $pick['b3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['12'] == $pick['b4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['13'] == $pick['b5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['14'] == $pick['b6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['15'] == $pick['b7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['16'] == $pick['b8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['17'] == $pick['c1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['18'] == $pick['c2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['19'] == $pick['c3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['20'] == $pick['c4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['21'] == $pick['c5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['22'] == $pick['c6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['23'] == $pick['c7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['24'] == $pick['c8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['25'] == $pick['d1'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['26'] == $pick['d2'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['27'] == $pick['d3'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['28'] == $pick['d4'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['29'] == $pick['d5'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['30'] == $pick['d6'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['31'] == $pick['d7'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } if ( $win['32'] == $pick['d8'] ) { $total = $value + $total; $rnd1 = $value + $rnd1; mysql_query("UPDATE `userpoints` SET `total`='$total', `rnd1`='$rnd1' WHERE `username`='$user'"); } } //End Loop print '</div>'; include ("style/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476725 Share on other sites More sharing options...
DarkerAngel Posted February 26, 2008 Share Posted February 26, 2008 at the end of each of your mysql_query add or die(mysql_error()) to see if any errors get reported back $result=mysql_query('SELECT * FROM userspoints') or die(mysql_error()); // Line #5 Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476728 Share on other sites More sharing options...
Lamez Posted February 26, 2008 Author Share Posted February 26, 2008 You know, I missed spelt the name of the table, I feel really dumb, I think I should go to bed. thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/93041-drivin-me-crazy/#findComment-476730 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.