This topic is locked

Insert into error

11/8/2009 7:20:16 PM
PHPRunner General questions
L
lostinwoods author

HI Everyone
I have two tables with following fields

Table1: ID, Name, Type

Table2: ID_a, Name_a, Address
I want to add the added record in table 2 based on value of Type in Table 1
Now I know I can add event after a new record is added but somehow don;t seems to work. I have looked at
""global $conn;$strSQLInsert = "insert into TableName (Field1, Field2) values (Value1, Value2)";db_exec($strSQLInsert,$conn);""
but not sure how to use this
is this the right way

global $conn;

$strSQLInsert = "insert into Table2 (ID_a, Name_a) values (ID, Name) from Table1 where Type = "company"";

db_exec($strSQLInsert,$conn);
For eg:

Table1: ID = 1

Table1: Name = abc

Table1: Type = company
Now with add record event I want to add this into Table2 as well only where Type matches
I'm getting all sorts of errors from SQL Syntax to Operand columns and MYSql server etc
I'm using Wamp server

Server Configuration

Apache Version :2.2.11 PHP Version :5.2.11

MySQL Version :5.1.36
Can anyone please help me?

J
Jane 11/9/2009

I recommend you to publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

L
lostinwoods author 11/9/2009

Thank you , I have solved it, Turns out to be simple MYSql syntax error.