Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql database insert is changing all IDs to 4294967295

Something really weird is going on with my database. I am using PHP to insert data into my database and I have been doing this for the past 2 years without any problems. When a customer makes a payment on my website, I store all of the data from that transaction in my database. Each transaction has a unique "transaction_id". When I insert the payment information into the database, all of the information is correctly inserted except for the "transaction_id". ALL transactions are given the "transaction_id" of "4294967295". So I did some testing. Here is what I did:

1) I echoed out the "transaction_id" to my screen to see what is would say. The results were that the "transaction_id" that was being echoed out was CORRECT. It was not the repeating "4294967295". However, when I look in my database, it shows "4294967295".

2) This time I decided to echo out the query to my web browser. The query was CORRECT. In the query, the CORRECT "transaction_id" was in the query. However, when I look in my database, it shows "4294967295".

I have 3 different pages where customers can make payments. ALL 3 pages started doing this on April 6th, 2012. None of those pages were modified at all. I have not modified those pages in over 2 years. Any help is greatly appreciated!

$query = "INSERT INTO payments (customer_id, transaction_id, invoice_number, authorization_code, subscription, subscription_id, avs_result, cvv_result, amount, full_tuition, payment_date, ip_address) VALUES ({$_SESSION['customer_id']}, {$_SESSION['transaction_id']}, {$_SESSION['invoice_number']}, '{$_SESSION['authorization_code']}', '{$_SESSION['subscription']}', {$_SESSION['subscription_id']}, '{$_SESSION['avs_result']}', '{$_SESSION['cvv_result']}', {$_SESSION['amount']}, {$_SESSION['full_tuition']}, '{$_SESSION['payment_date']}', '{$_SESSION['ip_address']}')" ;
$result = mysqli_query($dbc, $query) OR die ('<p>There was an error with the INSERT payments query.: ' . mysqli_error($dbc) . '<br />Query:' . $query . '</p>') ;

echo '<p>Transaction ' .  $_SESSION['transaction_id'] . ' has been <font color="green">APPROVED</font> by the system.</p>' ;

echo '<br /><br />' ;

echo '<p>Below is a summary:</p>' ;
echo '<p>Transaction ID: ' .  $_SESSION['transaction_id'] . '<br />
Payment Method: XXXX<br />
Amount: $' . $amount . '<br />
Customer Name: ' . $_SESSION['first_name'] . ' ' . $_SESSION['last_name'] . '<br />
</p>' ;

echo "<p>Note: Please do NOT click the browser's Back button to enter a new transaction.</p>" ;


echo $query ;
like image 770
three3 Avatar asked Apr 11 '12 17:04

three3


People also ask

What is Smallint in MySQL?

SMALLINT is a small integer. The SMALLINT range for SIGNED values is from -32768 to 32767. The minimum and maximum values for SMALLINT UNSIGNED are 0 and 65535 respectively. The size is 2 bytes per row.

What does INT 4 mean in MySQL?

For example, INT(4) specifies an INT with a display width of four digits. This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces.

Is INT and integer same in SQL?

The int data type is the primary integer data type in SQL Server. The bigint data type is intended for use when integer values might exceed the range that is supported by the int data type.

What is Bigint data type in MySQL?

BIGINT is the MySQL data type that can be assigned to the columns of the table in which we want to store the whole numbers and we are aware that the range of the numbers that we will store in that column will be huge and not exceed the range of the BIGINT data type.


1 Answers

Your number is larger than the field in the DB can handle...

4294967295 is the largest number 32 bits can hold, your transaction ID is now larger than the numerical field your DB can hold.

like image 152
Speckpgh Avatar answered Oct 11 '22 09:10

Speckpgh