Re: PHP/mySQL dropping zeros after inserting number into record
| From: | Emilio Astarita | Date: | Sat, 16 Feb 2008 23:37:40 +0000 |
| Subject: | Re: PHP/mySQL dropping zeros after inserting number into record | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269420@lists.php.net to get a copy of this message | ||
Rob Gould <gouldimg@mac.com> writes:
> I've got a PHP script that inserts "00012345678" into a record in a
> mySQL database (it's a barcode). Things work ok unless the number has
> preceding zeros, and then the zeros get cut off and all I get is
> "12345678".
>
> I have the mySQL database fieldtype set to bigint(14). If the maximum
> length a barcode can be is 14, is there a better fieldtype to use that
> will keep the zeros?
Use ZEROFILL, example:
CREATE TABLE
db.table (
barcode integer(14) ZEROFILL NOT NULL
)
--
Emilio Astarita <emilio.astarita@gmail.com>