954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Weird Database Changing

Ive got the code:

[php]mysql_query("UPDATE members SET gold=gold+$sellprice WHERE email='$player[email]' ")or die(mysql_error());[/php]

To add gold to a users account in the database but this doesn't work every time I run the script instead of adding on the new value to the old one it just
sets the gold to zero, ive tried echoing $sellprice and it does contain values and Ive checked the database and everything is valid.

Any ideas?

Ries
Newbie Poster
20 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This is really a SQL question... It's best asked at the SQL forum.

I think your problem is here, though:

SET gold=gold+$sellprice


Get gold from the database first, do the math, then set gold='$newgoldamount'

At least that's how I'd do it...

Puckdropper
Posting Pro
500 posts since Jul 2004
Reputation Points: 23
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You