Jump to content

Code not working. MySQL.


smithmr8

Recommended Posts

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.

 

 

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.