0

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';}

    ?>
3
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by iamthwee
0

Table name paymentmethod

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

0

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';
}
0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.