Weird Database Changing

Reply

Join Date: Apr 2006
Posts: 20
Reputation: Ries is an unknown quantity at this point 
Solved Threads: 0
Ries Ries is offline Offline
Newbie Poster

Weird Database Changing

 
0
  #1
Oct 17th, 2006
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: Weird Database Changing

 
0
  #2
Oct 18th, 2006
This is really a SQL question... It's best asked at the SQL forum.

I think your problem is here, though:
  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...
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC