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
https://forums.phpfreaks.com/topic/91547-code-not-working-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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