Jump to content

Prevent Duplicate UPDATE's


markvaughn2006

Recommended Posts

Hi, you guys have really helped me out!!

 

I'm trying to update a users "gold" but I don't want them to be able to hit refresh and keep adding gold. Also this is what I have now

 

mysql_query("UPDATE users_tbl SET gold = '100'

WHERE user_name = '$_SESSION[myusername]' ");

 

but obviously this sets "gold" to 100 it doesn't add 100 to "gold", how would I go about doing that? Thanks again guys!!

Link to comment
Share on other sites

PARTIALLY SOLVED :you are guys are great, but still have the problem that if you hit refresh it adds 100 gold every time, any idea how to prevent this?

 

$result = mysql_query("SELECT * FROM users_tbl

WHERE user_name='$_SESSION[myusername]'") or die(mysql_error()); 

$row = mysql_fetch_array( $result );

// Print out the contents of each row into a table

$gold = $row['gold'] + '100';

mysql_query("UPDATE users_tbl SET gold = '$gold'

WHERE user_name = '$_SESSION[myusername]' ");

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.