This topic is locked

Update 2 fields simultaneously

7/17/2011 2:07:53 PM
PHPRunner General questions
S
starkeyr author

Hi All
I have a problem that on the face of it seems really simple.
I have a database table containing 2 fields AccessCode and NewCode. When a new user registers they key in the Access code number and submit the registration form.
When the form is submitted I needed not only the AccessCode field to update but also the NewCode field as well. I can get the AccessCode updted via PHP Runner but cant get the NewCode field updated at the same time.
I have tried using various codes in the After Sucessfull registration (events.php) page but every time I get an Undifined Variable BoxNo error.
I have attached an example of the code I am using. I know what the error means but I do not know how to get PHP running to use the $BoxNo varialbe passed from the registration form
Example Code

global $conn;

$strUpdate = "update DeliveryWorksUsers set new_code='".$BoxNo."' where username='".$_SESSION["UserID"]."'";

db_exec($strUpdate,$conn);
Any help would be much apreciated

Sergey Kornilov admin 7/17/2011

An excerpt from http://www.1keydata.com/sql/sqlupdate.html

It is also possible to UPDATE multiple columns at the same time. The syntax in this case would look like the following:

UPDATE "table_name"

SET column_1 = [value1], column_2 = [value2]

WHERE {condition}