mySQL removes first digit

Posted by kielie on Stack Overflow See other posts from Stack Overflow or by kielie
Published on 2010-04-12T12:01:55Z Indexed on 2010/04/12 12:13 UTC
Read the original article Hit count: 384

Filed under:
|
|

Hi guys, I am inputting data into a mySQL database via a PHP script, but for some reason when I check the database, all of the phone numbers have their first digit removed, like so, 0123456789 shows up as 123456789 in the database, but if I change the data type from INT to TEXT, it shows correctly, I am very hesitant to keep it as TEXT though, as I am sure this will cause complications further down the road as the database app starts to become more complicated, here is the PHP code.

    <?php


$gender = $_POST['gender']; 

$first_name = $_POST['first_name']; 

$second_name = $_POST['second_name']; 

$id_number = $_POST['id_number']; 

$home_number = $_POST['home_number']; 

$cell_work = $_POST['cell_work']; 

$email_address = $_POST['email_address']; 


        $curDate = date("Y-m-d");

        mysql_connect ("server", "user", "pass") or die ('Error: ' . mysql_error());
        mysql_select_db ("database");

        $query = "INSERT INTO table (id,gender,first_name,second_name,id_number,home_number,cell_work,email_address,date) VALUES('NULL','".$gender."','".$first_name."','".$second_name."','".$id_number."','".$home_number."','".$cell_work."','".$email_address."','".$curDate."' )";

        mysql_query($query) or die (mysql_error());

        ?>

Thanx in advance!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php