Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try {
- $host="localhost"; $dbname="login"; $user="xxx"; $pass="xxx";
- $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
- $stmt = $dbh->prepare("INSERT INTO test (name) VALUES(?)");
- try {
- $dbh->beginTransaction();
- $stmt->execute( array('fehshfjk'));
- $dbh->commit();
- print $dbh->lastInsertId();
- } catch(PDOExecption $e) {
- $dbh->rollback();
- print "Error!: " . $e->getMessage() . "</br>";
- }
- } catch( PDOExecption $e ) {
- print "Error!: " . $e->getMessage() . "</br>";
- }
- ?>
Add Comment
Please, Sign In to add comment