This topic is locked

event - after record added

2/10/2008 12:16:10 AM
PHPRunner General questions
T
timsayles1 author

I need some clarification. I am trying to added data to another table once a new record is added on the first table.
I have the event, after record added with the following code:
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into encounter (id, customer, contact) values (.$values["customerid"], .$values["companyname"], .$values["contactname"])";

db_exec($strSQLInsert,$conn);
But this does not work and I totally cannot figure it out.
customerid, companyname, and contact name are the field names of the new record being added in the first table.. I want the values for those field to poplulate fields id, customer, and contact in the second table.
Thanks in advance!!!!!!

H
HMIS 2/10/2008

I need some clarification. I am trying to added data to another table once a new record is added on the first table.

I have the event, after record added with the following code:
//** Insert a record into another table ****

global $conn;

$strSQLInsert = "insert into encounter (id, customer, contact) values (.$values["customerid"], .$values["companyname"], .$values["contactname"])";

db_exec($strSQLInsert,$conn);
But this does not work and I totally cannot figure it out.
customerid, companyname, and contact name are the field names of the new record being added in the first table.. I want the values for those field to poplulate fields id, customer, and contact in the second table.
Thanks in advance!!!!!!


It looks like your missing a "

Try replacing (.$values["customerid"], .$values["companyname"], .$values["contactname"])";

with (".$values["customerid"], .$values["companyname"], .$values["contactname"])";
Let me know if it works

J
jclout 2/10/2008



It looks like your missing a "

Try replacing (.$values["customerid"], .$values["companyname"], .$values["contactname"])";

with (".$values["customerid"], .$values["companyname"], .$values["contactname"])";
Let me know if it works


I have tried doing it many different ways but the closest I get I still get an error : Undefined variable: conn

Can't figure way am getting this error. When I try to declare it I get an error that the variable is already declared.

What am I doing wrong.

A
alang 2/11/2008

Try:
global $conn;

$strSQLInsert = "insert into encounter (id, customer, contact) values ('".

$values["customerid"]."','".

$values["companyname"]."','".

$values["contactname"]."')";

db_exec($strSQLInsert,$conn);