You have a problem, what if the first insert give a error, then you don't know. You have to check each statement for error and if no error if found in all the statements then issue a commit if not a rollback
Osvaldo Sommer -----Original Message----- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: Saturday, October 16, 2004 7:19 AM To: [EMAIL PROTECTED] Subject: Transactions - working but unsure about steps My statements are all working but I'm not sure if things are set up correctly. I say this because at one point the first $query failed, yet the rest of inserts wre committed. Now I believe I need to set autocommit to 0 , yet the query failed due to a syntax error. Hence the rule about 0 records effected wouldn't be the case here. Here is what I have: //Create these functions - function begin() { mysql_query("BEGIN"); } function commit() { mysql_query("COMMIT"); } function rollback() { mysql_query("ROLLBACK"); } connection statement with error checking........... begin(); // transaction begins $query = "INSERT INTO firsttable.....//first query $result = mysql_query($query); // process first query $query = "INSERT INTO secondtable...//second query $result = mysql_query($query); // process second query $query = "INSERT INTO thirdtable....//third query $result = mysql_query($query); // process third query then: if(!$result) { echo mysql_errno($link) . ": " . mysql_error($link). "\n"; rollback(); // transaction rolls back exit; } else { commit(); // transaction is committed echo "your insertion was successful"; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.778 / Virus Database: 525 - Release Date: 10/15/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.778 / Virus Database: 525 - Release Date: 10/15/2004 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]