Please help me..I've the following code and I entered an account number in bank account number field but in database was changing the value. what's wrong?

My input in bank account number field is :112046067391
but the output is :2147483647

In database I set it to int(20) but still the same.

                <form name="addpayment" method="post" action="addpaymentmethod.php">
<table width="700px">

<tr>
 <td valign="top">
  <label for="shoptitle">Bank Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="bankname" maxlength="50" size="30" />
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="prefix">Bank Account Number </label>
 </td>
 <td valign="top">
  <input  type="text" name="acc" size="30" />
 </td>
 </tr> 
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Add Now"> 
 </td>
</tr>
</table>
</form>
            </div>
    <?php
    if(isset($_POST['bankname'])){
        if(isset($_POST['acc'])){
    mysql_query("INSERT INTO paymentmethod (PaymentName,AccountNumber) VALUES('$_POST[bankname]','$_POST[acc]')") or die (mysql_error());


        }else{echo'Please enter your bank account number';}
    }else{echo'Please enter your bank name';}

    ?>

Recommended Answers

All 7 Replies

how is you db table set?

can you provide your table structure?

Table name paymentmethod

ID (int(8))
PaymentName(varchar(30))
AccountNumber(int(20))

tested this:

if(isset($_POST['bankname']))
{
    if(isset($_POST['acc']))
    {
        $con = mysql_connect("localhost","root",""); // change to your details

        mysql_select_db("test",$con); // change test to your DB
        $sql = "INSERT INTO `paymentmethod`(`id`,`PaymentName`,`AccountNumber`) VALUES('','$_POST[bankname]','$_POST[acc]')";
        mysql_query($sql,$con);
        mysql_close($con);
    }
    else
    {
        echo'Please enter your bank account number';
    }
}
else
{
    echo'Please enter your bank name';
}

Sir, My previous code is work fine but only account number field goes wrong. I can't define where is the error . Once I change to varchar(20) it's work fine. Don't know where's the error.

Sorry forgot to add i change AccountNumber to bigint(20)

That was where the problem was

Can you elaborate why should I change it to bigint(20)? It seem like normal integer. Sorry,I'm new to php.

Member Avatar for iamthwee

Why the hell are you setting your bank account field as an integer?

Ummm varchar(50) ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.