i got a point system where people can buy diffrent things for points they get. Now i’m going to make so people can upgrade to [PRO] user. when they register they get logged in mysql as [user]. I’m making a code so that after action they lose 50 points and their [user] get replaced with [PRO]. but now i’m, with the replacement with [pro]. this is the code i have:
$insert = "UPDATE `users` SET `points` = (`points`-50) WHERE `username` = '".$username."' and points > 50";
mysql_query($insert);
if (mysql_affected_rows() > 0)
{
// other codes
$insert = "UPDATE users SET rights=' [user]' WHERE rights=' [pro]' WHERE `username` = '".$username."'";
mysql_query($insert);
header('location: succes.php');
}else{
echo "You don't have enough points to upgrade to [PRO]";
}
Instead of:
Try:
You have two
WHEREclauses and that won’t work. Just update their rights to pro once you take away 50 points.You could also combine your first and second queries with something like this: