Re:Instest of add, subtract

From: Date: Sun, 24 Feb 2002 01:11:19 +0000
Subject: Re:Instest of add, subtract
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17233@lists.php.net to get a copy of this message
I (too often) find that odd behavior like this is because one of the variables is set incorrectly (not what I expected) even if it sometimes works. A very useful debugging technique is to print out $query just before you send it to the DB. You might be surprised at what you're sending. Personally I like to leave it printing $query until I've got all the code working well and am polishing us the App. It's hard to tell what you're sending to the DB as we don't know what's in $user_deposit and how PHP is interpreting it. Print out $query - that's where the "beef" is anyway... Frank On 2/23/02 12:02 PM, "php-db-digest-help@lists.php.net" <php-db-digest-help@lists.php.net> wrote: > > From: "Jennifer Downey" <jendowney@attbi.com> > Date: Sat, 23 Feb 2002 10:26:27 -0800 > To: php-db@lists.php.net > Subject: Instest of add, subtract. > > 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

« previous php.db (#17233) next »