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
https://forums.phpfreaks.com/topic/174030-prevent-duplicate-updates/
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]' ");

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.