944,204 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1161
  • PHP RSS
Oct 17th, 2006
0

Weird Database Changing

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ries is offline Offline
20 posts
since Apr 2006
Oct 18th, 2006
0

Re: Weird Database Changing

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

I think your problem is here, though:
PHP Syntax (Toggle Plain Text)
  1. 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...
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need help with forum mailing
Next Thread in PHP Forum Timeline: data output





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC