MafiaHeros Posted May 14, 2012 Share Posted May 14, 2012 I'm trying to make a colour name buyer... Everything works except one thing... It does not change the users table but it should of.. This is the code: if ($user_class->points > 2000 && $_POST['color'] != "agree"){ $colours = "" . $_POST['color'] . "~" . $_POST['color']; $colours = (isset($_POST['color'])) ? $colours . "~" . $_POST['color'] : $colours; $player = $user_class->id; $gradient = 3; $cost = $user_class->points - 2000; $player_class = new User($player); $result1 = mysql_query("UPDATE `grpgusers` SET `gradient`='3' WHERE `id` = '".$player."'"); $result = mysql_query("UPDATE `grpgusers` SET `colours` = '".$colours."' WHERE `id` = '".$player."'"); $result = mysql_query("UPDATE `grpgusers` SET `points` = '".$cost."' WHERE `id` = '".$player."'"); echo Message("You have successfully changed your gradient colours."); } Everything above works, except this line: $result1 = mysql_query("UPDATE `grpgusers` SET `gradient`='3' WHERE `id` = '".$player."'"); When the gradient is below the amount of 3, it will not show. But it should update it into the database once I click submit, strange thing is, it does take the points and updates the RGB color code. Anyone know a solution on this? Much appreciated. Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 14, 2012 Author Share Posted May 14, 2012 By the way, $result1 = mysql_query("UPDATE `grpgusers` SET `gradient`='".$gradient."' WHERE `id` = '".$player."'"); does not work either.. :rolleyes: Quote Link to comment Share on other sites More sharing options...
sniko Posted May 14, 2012 Share Posted May 14, 2012 When you say "Does not work", can you expand...? What result does it give, if any Have you used the 'debug' feature (or die(mysql_error());) Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 14, 2012 Author Share Posted May 14, 2012 The line that's not working is this one $result1 = mysql_query("UPDATE `grpgusers` SET `gradient`='3' WHERE `id` = '".$player."'"); I want it to change once a user clicks the submit button. I have looked in php my admin to see if it changed but it just stays at 0. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted May 14, 2012 Share Posted May 14, 2012 Could we get the structure of the "gradient" field? Also you should combine all these queries into 1. $result=mysql_query("UPDATE `grpgusers` SET `points` = `points`-2000, `colours` = '$colours', `gradient` = '3' WHERE `id` = '$player'"); Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted May 14, 2012 Share Posted May 14, 2012 When the gradient is below the amount of 3, it will not show. But it should update it into the database once I click submit, strange thing is, it does take the points and updates the RGB color code. Anyone know a solution on this? Much appreciated. You have the gradient set at the value of 3, so it will only update to 3 nothing more nothing less... Quote Link to comment Share on other sites More sharing options...
URBANZ Posted May 14, 2012 Share Posted May 14, 2012 (edited) first off i would change the query a little bit i haven't tested but should work if ($user_class->points >= 2000 && $_POST['color'] != "agree"){ $colours = "" . $_POST['color'] . "~" . $_POST['color']; $colours = (isset($_POST['color'])) ? $colours . "~" . $_POST['color'] : $colours; $result = mysql_query("UPDATE `grpgusers` SET `points` = `points` - 2000, `colours` = '".$colours."', `gradient`='3' WHERE `id` = '".$user_class->id."'"); echo Message("You have successfully changed your gradient colours."); } P.S ive shortened the code down alot as for 1 u dont need to redeclare user class unless you using it to fetch something instead of current user and alot of code was not needed for code you posted Edited May 14, 2012 by urbanmafia Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted May 14, 2012 Share Posted May 14, 2012 You have the gradient set at the value of 3, so it will only update to 3 nothing more nothing less... He knows that. What he's trying to figure out is why it's NOT updating to 3. Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 14, 2012 Author Share Posted May 14, 2012 Nevermind, works now. Thanks... Solution: $result = mysql_query("UPDATE `grpgusers` SET `gradient?` = '".$type."', `colours` = '".$colours."' WHERE `id` = '".$player."'"); $result = mysql_query("UPDATE `grpgusers` SET `colours` = '".$colours."' WHERE `id` = '".$player."'"); $result = mysql_query("UPDATE `grpgusers` SET `points` = '".$cost."' WHERE `id` = '".$player."'"); Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 15, 2012 Share Posted May 15, 2012 Why are you doing two queries for colours? This should be all one query. Quote Link to comment Share on other sites More sharing options...
MafiaHeros Posted May 15, 2012 Author Share Posted May 15, 2012 Because I was still fixing it, thats why I did the queries in 3 lines, makes it easier for me to see what im doing wrong. :) Quote Link to comment Share on other sites More sharing options...
Uridium Posted May 15, 2012 Share Posted May 15, 2012 $result = mysql_query("UPDATE `grpgusers` SET `gradient?` = '".$type."', `colours` = '".$colours."', `points` = '".$cost."' WHERE `id` = '".$player."'"); // will work just as well as what youve written // 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.