smithmr8 Posted February 17, 2008 Share Posted February 17, 2008 Hi, The following code doesn't seem to work. The first part, 'sday' works, however the 'bday' does not. <?php if($_GET['step'] == 'sday') { if ($x['money'] >= 250) { mysql_query("UPDATE users SET sdays = sdays+1 WHERE ID = $x[iD]"); mysql_query("UPDATE users SET money = money-250 WHERE ID = $x[iD]"); echo "You bought a Shareholder Day for £250."; } else { echo "You do not have enough money to buy one of these. Try working some more, bum."; } } if($_GET['step'] == 'bday') { if ($x['sdays'] > 0) { mysql_query("UPDATE users SET sdays = sdays-1 WHERE ID = $x[iD]"); mysql_query("UPDATE users SET money = money+175 WHERE ID = $x[iD]"); echo "You sold a Shareholder Day for £175."; } else { echo "You do not have any Shareholder Days to sell. We aint no fools."; } } ?> sdays = table field The first part works perfectly. If the person has the money, then the updates take place. Else, it jumps to the else clause. The second part however, seems to be jumping directly to the else clause, or something else is wrong. Quote Link to comment Share on other sites More sharing options...
smithmr8 Posted February 17, 2008 Author Share Posted February 17, 2008 OH, and the $x is all fine. It corresponds to this code in the header file. $user = $_SESSION['myusername']; $info="SELECT * FROM users WHERE username='$user'"; $result_info = mysql_query($info); $x=mysql_fetch_array($result_info); Quote Link to comment Share on other sites More sharing options...
Barand Posted February 17, 2008 Share Posted February 17, 2008 try echo $x['sdays']; and check the value Quote Link to comment Share on other sites More sharing options...
smithmr8 Posted February 17, 2008 Author Share Posted February 17, 2008 Its decided to work now. I'm not sure why it wasn't working before, but all seems well now. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 17, 2008 Share Posted February 17, 2008 For future reference, this rule still holds true "If the output isn't what you expected, check the input" Quote Link to comment Share on other sites More sharing options...
smithmr8 Posted February 17, 2008 Author Share Posted February 17, 2008 Yeah. Thanks. 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.