Jump to content
MakeWebGames

Help?


MafiaHeros

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by urbanmafia
Link to comment
Share on other sites

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."'");

Link to comment
Share on other sites

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.   Paste as plain text instead

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