On Sat, February 16, 2008 5:22 pm, Rob Gould wrote: > 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? > > (or some way for PHP to tell mySQL not to chop off the zeros?) I personally would have used char(14) for a barcode, since it's really a 14-character fixed-width thing. You could use formatting on the output to get the leading zeros: sprintf("%0,14d", $barcode); //or somesuch http://php.net/sprintf And comparisons within MySQL should type-juggle to int, and make things work out... So, really, the bigint(14) should be okay, once you format the output to "look right" -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php