Jump to content

Drivin Me Crazy


Lamez

Recommended Posts

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");  
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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");  
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.