I need to insert data into two different tables in the same database using one button, but can't work out how.
My two insert commands look like this:
$insertSQL1 = sprintf("INSERT INTO table2...blah blah blah..."); // this is a whole load of info from the form
$insertSQL2 = ('INSERT INTO table2...blah blah blah...'); // this is some more data, including an array
I have tried putting them into a "BEGIN WORK... COMMIT WORK" function, as follows:
$insertSQL = "BEGIN WORK;
".$insertSQL1.";
".$insertSQL2.";
COMMIT WORK;";
...but I get always get the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO...'
I can't for the life of me work out what the actual syntax error is. Any suggestions on a better way of doing this?