Link to home
Start Free TrialLog in
Avatar of jonofat
jonofat

asked on

Inserting number that starts with 0 leaves off the 0

I am insterting a phone number in to a database and the number starts with 0. When I view the record it shows everything after the 0 but never shows the 0. I have changed the type in the database from integer to varchar to text and stll won't work!
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonofat
jonofat

ASKER

Hmm, okay. So what do I do for this?

<?php echo $row_Recordset1['contactno']; ?>

and also, users will be able to change their numbers to...

so, if they type 011 123 4567 is there no way to get it to store in the database like that?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonofat

ASKER

Well, what I did is in the update record code, I just changed it to

($_POST['contactno'], "text"),

instead of ($_POST['contactno'], "int"),

and that worked. Is it acceptable?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jonofat

ASKER

Thanks Ray. Yeah, an article about type juggling would be great!
Thanks for the points - it's a great question, and in particular it's one that I lost an entire morning to over the array index issues.  I wish PHP had a way to declare variables to be tightly typed (particularly arrays) so that it would throw an error if you used the == comparison instead of the === comparison!

Best regards, ~Ray