I'm using PDO::prepare() to prepare an INSERT statement. PDO::execute() returns true, and $dbh->lastInsertId() always has the next id, but no row is actually inserted!
What could be causing this?
I'm going to stab in the dark here and wager that you didn't run $dbh->commit() afterwards. Without the commit it will roll back the changes once your script ends or the connection is closed.
See also: Transactions and auto-commit
$dbh->commit() after the first insert, and it does show up correctly, but the second insert still throws a foreign-key constraint error. Any ideas why?