This topic is locked

Insert Recod in another table..

12/30/2008 8:06:50 AM
PHPRunner General questions
I
indigo author

I am trying to use events for inserting record in another table...

global $conn;
if ($values["Amount"]<> NULL)

{

$strSQLInsert = "insert into ware_fin_trn_gl (PYTID,Line,TRNID,Date,Department,Project,Createdby,Createdon,Notes,Cleared,L

ID,Ledger,Amount,AmtType,TrnType) values ('$values[PYTID]','1','$values[TRNID]','$values[Date]','$values[Department]','$values[Project]','$values[Createdby]','$values[Createdon]','NA','1','$values[PaidToLedger]','$values[PaidTo]','$values[Amount]','Dr','Payment Made')";

}
return true;


I have added the above in "After Record Add" page.
However, PYTID always is zero, even though the record shows that there is value in that field. So the record that is added is incorrect.

Can someone help?

A
alang 1/4/2009

Assume you mean that the record saved by PHPR (in the first table) shows a non-zero value for PYTID? Is this set up as an autoincrement field in the first table?

I
indigo author 1/15/2009

ya this is autoincrement field..
cant we insert that data?

J
Jane 1/15/2009

Hi,
to select ID of added record use mysql_insert_id() function:

$id = mysql_insert_id();