PDA

View Full Version : Problem with copying one field to anouther


tyanque
08-16-2009, 09:08 PM
Hey, I'm trying to copy the contents of one field to the other but I do so the query returns Resource id #8. Here is my query:
UPDATE users SET field1 = '{$code}' WHERE UserID = '{$uid}';

$code is the contents of the other field.

Anyone know what the problem is? Thanks.

ckeyrouz
08-16-2009, 09:12 PM
What is the name of the other field that you are trying to read data from?

tyanque
08-16-2009, 09:14 PM
the other field is called UserActivationCodeConf

ckeyrouz
08-16-2009, 10:05 PM
As I see you are making a query 1 using it to get the value of the field UserActivationCodeConf and then you are using another query 2 to update the field "field1 ".

I hope I did not understand the issue in a wrong way.

The best way to do this is one query:
UPDATE users SET field1 = UserActivationCodeConf WHERE UserID = '{$uid}';

Update on the fly set the value in the field 1 = the value in the field2 of the same row.