Re: Instest of add, subtract.
| From: | Bogdan Stancescu | Date: | Sat, 23 Feb 2002 23:46:51 +0000 |
| Subject: | Re: Instest of add, subtract. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17230@lists.php.net to get a copy of this message | ||
Well, there are quite some differences difference between the results these two pieces of code yield. Let's see what your sql query would be for the first version, replacing $deposit in $query:
UPDATE wt_users set bank_points + $user_depositset points - $user_deposit WHERE uid={$session["uid"]}
^1 ^2 ^3whereas we probably want UPDATE wt_users set bank_points=bank_points + $user_deposit, points=points - $user_deposit WHERE uid={$session["uid"]} I marked the three problems in your original code (you'll want to use a fixed character to see them properly): 1. set who to this value? 2. There must be a space there 2bis. set and set don't go well together - we want a comma instead 3. same as 1 OTOH, you may want to get rid of those brackets in $query=("...") - they really don't do anything... HTH Bogdan Jennifer Downey wrote:
Hi, Instead of helping with my other question maybe you can tell me why this wont work? Is it not valid ? Can you not use strings in a query like this? $deposit="set bank_points + $user_deposit"; $deposit .="set points - $user_deposit"; $query = ("UPDATE wt_users $deposit WHERE uid={$session["uid"]}" ); $result=mysql_query("$query"); if set like this it will update the points in the bank_points but not the points table. $db["bank_points"]=("UPDATE wt_users set bank_points = bank_points + $user_deposit WHERE uid={$session["uid"]}" ); $result=mysql_query($db["bank_points"]); Thanks in advance Jennifer Downey