...

View Full Version : Multiple table insertion



batowiise
05-19-2011, 11:16 AM
Hi All,

I want to keep audit of transactions. I have two tables, one acting as the main table and the other acting as a copy of the main table (audit) with some of the field copied to the audit table.

The following is my code but data is not been written to the audit table.

Your help is welcome




$traveller = $_REQUEST['traveller'];
$requestdate = $_REQUEST['requestdate'];

require_once("../admin/db.php");

$sqlinsert="INSERT INTO `internationaltravel` (`traveller`,`requestdate`)
VALUES ('$traveller','$requestdate')";

mysql_query($sqlinsert);

$last_inserted_id = mysql_insert_id();

$sqlinsert_audit="INSERT INTO `audit` (`date`,`initiator`,`transid`)
VALUES ('$requestdate','$traveller',$last_inserted_id)";

InterbredMonkey
05-19-2011, 01:04 PM
Is there more code? If not you havent even performed the SQL query on $sqlinsert_audit.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum