PHP inserts another value into the database!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oskare100
Forum Commoner
Posts: 80
Joined: Sun Oct 29, 2006 5:47 am

PHP inserts another value into the database!

Post by oskare100 »

Hello,
$item_number is one value but the MySQL querey inserts another.

Code: Select all

Here is the code:
$item_number = $_POST['item_number'];

$sql46="INSERT INTO $sales_tbl (user_id, pack_id, ebay_item_name,	ebay_item_id, ebay_txn_id, shipped_marked, paid_marked, payment_status, payment_date, payment_gross, payment_tax, payment_currency, payment_type, paypal_txn_id, paypal_memo, auction_closing_date, auction_multi_item, received) VALUES('".$row['user_id']."', '".$ident_row['file_id']."', '$item_name', '$item_number', '$ebay_transaction_id', '$shipped_marked', '$paid_marked', '$payment_status', '$payment_date', '$mc_gross', '$tax', '$mc_currency', '$payment_type', '$txn_id', '$memo', '$auction_closing_date', '$auction_multi_item', NOW())";
$result46=mysql_query($sql46) or die( mysql_error() );
}

//Send new purchase message to buyer
$to      = "me@me.com";
$subject = 'subject';
$message = "
Item number: $item_number
";
$headers = 'From: sales@ventiero.com' . "\r\n" .
  'Reply-To: sales@ventiero.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
$item_number = 110079832134, and that's also the item number that is emailed to be. But when I look at the database 2147483647 has been inserted instead!? And it always inserts 2147483647 instead of the actual number so please help me, what's wrong?? The database ebay_item_id is int(15).

Thanks in advance,
/Oskar R
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Post by waqas_punjabian »

Try the following ::

Code: Select all

Here is the code:
$item_number = $_POST['item_number'];

$sql46="INSERT INTO $sales_tbl (user_id, pack_id, ebay_item_name,       ebay_item_id, ebay_txn_id, shipped_marked, paid_marked, payment_status, payment_date, payment_gross, payment_tax, payment_currency, payment_type, paypal_txn_id, paypal_memo, auction_closing_date, auction_multi_item, received) VALUES('".$row['user_id']."', '".$ident_row['file_id']."', '$item_name', '".$item_number."', '$ebay_transaction_id', '$shipped_marked', '$paid_marked', '$payment_status', '$payment_date', '$mc_gross', '$tax', '$mc_currency', '$payment_type', '$txn_id', '$memo', '$auction_closing_date', '$auction_multi_item', NOW())";
$result46=mysql_query($sql46) or die( mysql_error() );
}

//Send new purchase message to buyer
$to      = "me@me.com";
$subject = 'subject';
$message = "
Item number: $item_number
";
$headers = 'From: sales@ventiero.com' . "\r\n" .
  'Reply-To: sales@ventiero.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

or else check ur database field type. It must be compatibe to the data u r sending.

I think ur database field size is shorter. Try to increase the length of the field.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$item_number is WAY over the upper limit to normal integers. You need to either switch to BIGINT or a CHAR type.
Post Reply