This topic is locked

Insert a record into another table

10/28/2012 12:31:59 AM
PHPRunner General questions
R
rustler45 author

I cant seem to get anything to work with this PHPRunner. I have two tables. MainData with fields CustomerName and DealerNumber, and ContractData with ecustname and edealername. I am using the built in "Insert a record into another table" I click on the link and get this:
global $conn;
$strSQLInsert = "insert into TableName (Field1, Field2)
values (Value1, Value2)";
db_exec($strSQLInsert,$conn);
While in PHPRunner of my MainData, I replace the TableName, Field1, Field2, and Value1, Value2 with mine like this:
global $conn;
$strSQLInsert = "insert into ContractData (ecustname, edealername)
values (CustomerName, DealerNumber)";
db_exec($strSQLInsert,$conn);
But this doesnt work. I keep getting an error:
Error type 256

Error description Unknown column 'CustomerName' in 'field list'

URL www.XXXXXXXXXX.com/testfolder/MainData_add.php?ferror=1&;

Error file /XXXXX/XXXXXX/public_html/testfolder/include/dbconnection.my.mysqli.php

Error line 42

SQL query insert into ContractData (ecustname, edealername) values (CustomerName, DealerName)
I have changed this every way I can think of and keeping errors. Anybody know what I am doing wrong, please help.

C
cgphp 10/28/2012

I don't see data values in your query. Check the correct INSERT statement syntax: http://www.w3schools.com/sql/sql_insert.asp