ok Posted August 1, 2008 Share Posted August 1, 2008 ok i have these codes below. if($link!=$jtablegrid_link) { //this condition will limit the player from accidentally clicking the already taken number if($user_click<50) { //if user has tickets equal or greater than 1 if($balance_jackpot>=1 || $balance>=1) { //check record existence first before writing. $strQuery1 = "select count(*) as cnt from jtablegrid where box_no='".$link."'"; $res = mysql_query($strQuery1); $row = mysql_fetch_array($res); $intCount = $row['cnt']; if($intCount == 0) { $query = "INSERT INTO jtablegrid (username, box_no) VALUES ('$username','.$link.')"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); } //this will subtract balance and balance_jackpot. //everytime a user click it subtract 1 ticket from balance_jackpot column or from balance. if($balance_jackpot>=1) { $jackpot_subtracted = $balance_jackpot-1; //then update user table. $query = "UPDATE user SET balance_jackpot='$jackpot_subtracted' WHERE username='$username'"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); } elseif($balance>=1) { #$balance_original = $balance; #$balance = floor($balance); //round down. if($balance>=1){ $balance_tmp = $balance-1; //then update user table. $query = "UPDATE user SET balance='$balance_tmp' WHERE username='$username'"; mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); } } } else { echo "<br><br>"; echo "<b>Sorry, you don't have enough ticket.</b>"; echo "<br><br>"; } } else { echo "<br><br>"; echo "<b>You already reached the 50 click user limit per game.</b><br>"; echo "<b>Please wait for the next game, Thank you!</b>"; echo "<br><br>"; } } elseif($link==$jtablegrid_link) { echo "<br><br>"; echo "<b>That number is already taken.</b>"; echo "<br><br>"; } what really bother me is when this if below is false if($link!=$jtablegrid_link) it still execute the other if inside it. what do you think is a nice remedy for this? or do you see bugs on my if elseif statements? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
bretticus Posted August 1, 2008 Share Posted August 1, 2008 what really bother me is when this if below is false if($link!=$jtablegrid_link) it still execute the other if inside it. Impossible! That would totally make if statements worthless. Quote Link to comment Share on other sites More sharing options...
ok Posted August 1, 2008 Author Share Posted August 1, 2008 thanks for your comments my friend. but i'm going insane with this. is there a problem that you see in my codes? Quote Link to comment Share on other sites More sharing options...
bretticus Posted August 1, 2008 Share Posted August 1, 2008 Syntactically, everything looks fine. I will say that your elseif statement is completely redundant though. if($link!=$jtablegrid_link) // ... elseif($link==$jtablegrid_link) ...are always the inverse of each other. So if $link is not equal to $jtablegrid_link, than $link most certainly DOES equal $jtablegrid_link. All you need is an else statement. It would seem that the problems you are experiencing occur at or after the line: if($user_click<50) { Perhaps you can explain how that code is not working. Quote Link to comment Share on other sites More sharing options...
paul2463 Posted August 1, 2008 Share Posted August 1, 2008 bretticus is correct the elseif statement is redundant change it ofr a straight else such as } } else { echo "<br><br>"; echo "<b>That number is already taken.</b>"; echo "<br><br>"; } Quote Link to comment Share on other sites More sharing options...
ok Posted August 1, 2008 Author Share Posted August 1, 2008 thanks guys i already figured it out. the value of jtablegrid_link is empty. Quote Link to comment 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.