Re: Zeros get striped off my db entrees.... how to stop...

From: Date: Tue, 30 Jan 2001 09:51:47 +0000
Subject: Re: Zeros get striped off my db entrees.... how to stop...
Groups: php.general 
Request: Send a blank email to php-general+get-37274@lists.php.net to get a copy of this message
> Ok, I have a string of bits that I combine to store as the privilege level > for our users.... it is 5 chars long "12345", and the default is "00000" > this would be the most basic user. now, when there is a non 0 number at the > front.... it works.... and every thing is cool.... but, even though the > field is set as CHAR 5, if the privs number is set to 00110, it is stored in > the DB as 110.... or at least that is how it is retrieved.... in > PHPmyAdmin.... it shows up as 00110.... > > so anyway, somewhere it is stripping the leading 0's off the number, and I > need to know why and how to fix that..... This is a job for the SET data type in MySQL! Even though the SET type returns a list of legible strings it stores information in a bitmap, as compactly as possible. See: http://www.mysql.com/doc/S/E/SET.html If you can't switch to sets, consider switching to a string of non numeric characters, or make the first character in your string non numeric. It wont get mangled by type conversions, and leading zero supression that way. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.general (#37274) next »