This topic is locked

Events: Before record added help

7/24/2008 6:26:34 AM
PHPRunner General questions
author

I'm trying to insert an ID field value from one table into another table..creating a new record in that table.
It is creating the new record in the other table but the value in the field I'm trying to insert into is 0.
Here is the code i'm using in Events:
global $conn;

$strSQLInsert = "insert into jos_dtregister_field_event (event_id) values (id)";

db_exec($strSQLInsert,$conn);
Thanks in advance for any help!!

J
Jane 7/24/2008

Try to use following code:

global $conn;

$strSQLInsert = "insert into jos_dtregister_field_event (event_id) values (".$keys["id"].")";

db_exec($strSQLInsert,$conn);

501320 7/25/2008

Thank you that worked!
I do have aanother question.
I'm using this to try to get another field to write to a different table:
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into jos_dtregister_group_event (registerAmountIndividual) values (Individual_Amount)";

db_exec($strSQLInsert,$conn);
I keep getting this error:
Unknown column 'Individual_Amount' in 'field list'
I have checked and that is the correct field name for values. Is there a special way I have to put that in.
Thanks again for the help!

J
Jane 7/25/2008

Hi,
all entered values are stored in the $values array. For example: $values["FieldName"].

Here is a sample:

//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into jos_dtregister_group_event (registerAmountIndividual) values (".$values["Individual_Amount"].")";

db_exec($strSQLInsert,$conn);

501321 7/25/2008

Jane, thank you so much!!!