Re: Random data loss.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think I need to give more details. The data loss happens somewhere between the form post button press and the data being inserted into the DB. It is a simple sql insert statement on a table with auto increment keys. The price should be entered as a floating point number and that is what my user who had the problem happen did. 34.72 in one case. The price that ended up in the DB was zero. I tried to see if maybe there was a mistake by putting in two periods but that just makes it store 34.00 instead. I tried spaces around the numbers and that didn't have any effect. In every case where this has happened the user was able to use the web form for modifying the data and changed the price back, post the form which then executes an update sql statement and that corrected the data.

The only thing I can think might be the cause is the data is actually stored in 2 tables. The first table, "Gift", stores the basic information about the Gift you want and the second table, "Vendor", stores the information about where to get it as well as the price. I am including the the queries below. A quick not the Gift table is a double key table on UserKey and GiftKey and the Vendor table is a triple key table on UserKey, GiftKey and VendorKey. It was set up this way to allow a one to many relationship between Gift and Vendor, however at this time the relationship is always a one to one.

$query = "INSERT INTO Gift Values \n('$UserKey', NULL, '$Description', '$Qty', '0',\n";
$query .= "'$Manufacturer', '$ModelNum', '$InfoURL', '$ImageURL', '$Category',\n";
$query .= "'$Priority', '$AddDate', '$ExpireDate'\n)";
$result = mysql_query($query);
if(! $result){
$ErrorMsg = "I'm sorry, there was a database error, please try again later.<BR>\n" . mysql_error();
include 'AddGiftForm.php';
exit;
}


$GiftKey = mysql_insert_id($link);

$query1 = "INSERT INTO Vendor Values \n('$UserKey', '$GiftKey', NULL, '$Price', '$VName', '$VURL',\n";
$query1 .= "'$VStreetAddress', '$VCity', '$VState', '$VZIP', '$Phone')";
$result = mysql_query($query1);
if(! $result){
$ErrorMsg = "I'm sorry, there was a database error, please try again later.<BR>\n" . mysql_error();
include 'AddGiftForm.php';
exit;
}


Chris W

Gift Giving Made Easy
Get the gifts you want & give the
gifts they want this holiday season
http://thewishzone.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux