php - Having trouble getting the last id in MySQL -
i'm trying last id added database using mysql_insert_id
doesn't work. error is:
mysql_insert_id() [function.mysql-insert-id]: can't connect local mysql server through socket '/var/tmp/mysql.sock' (2) in /proj/co639/assessment2/nicp3/public_html/book_create.php on line 46
warning: mysql_insert_id() [function.mysql-insert-id]: link server not established in /proj/co639/assessment2/nicp3/public_html/book_create.php on line 46
i've done connection this:
$handle = new pdo( 'mysql:host=;dbname=', '', '');
what issue?
you looking this:
$handle->begintransaction(); // here execute query $handle->commit(); $id = $handle->lasinsertid();
your code won't work because mix 2 different classes.
more information can found here: http://php.net/manual/en/pdo.lastinsertid.php
Comments
Post a Comment