note 14869 added to function.mysql-insert-id.php
| From: | torray at juxtopia dot com | Date: | Sat, 18 Aug 2001 11:00:37 +0000 |
| Subject: | note 14869 added to function.mysql-insert-id.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16867@lists.php.net to get a copy of this message | ||
No, mysql_insert_ID() does not add zerofill. To fix:
$ID = mysql_insert_ID();
$ID = str_repeat("0", $sp - strlen($ID)).$ID;
** $sp is the max number of digits your ID column has (eg. INT(11) would yield $sp = 11)
http://www.php.net/manual/en/function.mysql-insert-id.php