Hi James,

Well if you used [VAR]CHAR/TEXT and then did the INSERT query *with* the
leading 0s, it should work. If the 0s aren't there in PHP, they won't be
stored in the CHAR column though.

But anyway, it's more efficient to stick with SMALLINT... and use the
ZEROFILL attribute on the column. :-) e.g.

phone1SUF SMALLINT(n) UNSIGNED ZEROFILL NOT NULL

where n is the number of leading 0s to prepend if needed to make the
display n digits long. With this method, you *don't need* the leading 0s
in your PHP variable. So just

"...SET phone1SUF = $tr_p1SUF..."

Hope that helps.


Matt


----- Original Message -----
From: "James Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 20, 2003 1:11 AM
Subject: INSERT/UPDATE number weirdness


> Hi,
>
> This is bugging me....
>
> Using PHP/MySQL.
>
> I have three input fields to hold a user's phone number. The MySQL
fields
> are set to SMALLINT. If any of the strings to update the DB starts
with a 0
> (zero), the first number is truncated (0206 becomes 206). Any other
> combination where the first digit is not a 0 works.
>
> I have tried both
> $tr_p1SUF = $_POST['phone1SUF'];
>
> "...SET phone1SUF = '$tr_p1SUF'..."
>
> AND
>
> "...SET phone1SUF = $tr_p1SUF..."
>
> I have tried changing the DB field types to char, int, text, varchar
>
> Idea, suggestions?
> Thanks,
> James


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to