Re: [PHP] Random data loss.

2004-12-07 Thread Richard Lynch
2wsxdr5 wrote:
 With out posting any code I was wondering if anyone here has been
 experiencing this kind of problem.  I have a standard web from that PHP
 code then reads and saves the data into a MySQL DB.  The problem is some
 of my users have had data lost somewhere in this process.  The web site
 is www.thewishzone.com.  It is a wish list site and the data that seems
 to be getting lost is the price of an item a user adds to their wish
 list.  I can't seem to duplicate it here.  However one user did have it
 happen twice in a short time period.  They enter a valid price and after
 the record posts the price goes to zero.  Any ideas?

How do you determine a valid price?

Do you allow the $ to be in it?  Cuz MySQL sure won't take that.

Very common mistake.

Are you checking mysql result for error in your INSERT and UPDATE
statements.  MySQL should not be losing data without SOME kind of
message...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Random data loss.

2004-12-07 Thread 2wsxdr5
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


[PHP] Random data loss.

2004-12-06 Thread 2wsxdr5
With out posting any code I was wondering if anyone here has been 
experiencing this kind of problem.  I have a standard web from that PHP 
code then reads and saves the data into a MySQL DB.  The problem is some 
of my users have had data lost somewhere in this process.  The web site 
is www.thewishzone.com.  It is a wish list site and the data that seems 
to be getting lost is the price of an item a user adds to their wish 
list.  I can't seem to duplicate it here.  However one user did have it 
happen twice in a short time period.  They enter a valid price and after 
the record posts the price goes to zero.  Any ideas?

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


RE: [PHP] Random data loss.

2004-12-06 Thread Vail, Warren
Could be a problem of multiple update modules for the same table.  When I've
encountered this problem in the past it's been one of two causes.

1.  In the process of maintaining the table one routine that has no price
information, retrieves the row and notices that the something needs to be
changed, and instead of only updating columns that have changed it seeks to
update all of them (perhaps satisfying one programmers sense of order), and
since it has no price info, it replaces the price with zero (good rule IMHO;
only update columns that you know need to be changed).

2.  Update queries that did not specify all the appropriate where clauses,
thereby updating multiple rows, and perhaps in this case updating with zero
prices (perhaps contributed to by coding all elements as above).  (a rule
that I apply to myself, not necessarily quite as good as the previous rule,
use artificial keys [auto increment fields] and update with unique [or a
list of] artificial key in the where clause).  One nice thing about auto
increment primary keys is they are self locking in that no two insert rows
can get the same artificial key, even if the insert occurs at the same time
(at least in MySQL).  Take a look at the text in your actual queries and
read them over and over, the answer is there.

Don't consider this an exhaustive list, there are lots of people out there
more clever than I coming up with new ways to loose data every day.  But
this is where I would start.

Hope this helps,

Warren Vail

 -Original Message-
 From: 2wsxdr5 [mailto:[EMAIL PROTECTED] 
 Sent: Monday, December 06, 2004 4:27 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Random data loss.
 
 
 With out posting any code I was wondering if anyone here has been 
 experiencing this kind of problem.  I have a standard web 
 from that PHP 
 code then reads and saves the data into a MySQL DB.  The 
 problem is some 
 of my users have had data lost somewhere in this process.  
 The web site 
 is www.thewishzone.com.  It is a wish list site and the data 
 that seems 
 to be getting lost is the price of an item a user adds to their wish 
 list.  I can't seem to duplicate it here.  However one user 
 did have it 
 happen twice in a short time period.  They enter a valid 
 price and after 
 the record posts the price goes to zero.  Any ideas?
 
 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
 

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



Re: [PHP] Random data loss.

2004-12-06 Thread Raditha Dissanayake
2wsxdr5 wrote:
With out posting any code I was wondering if anyone here has been 
experiencing this kind of problem.  I have a standard web from that 
PHP code then reads and saves the data into a MySQL DB.  The problem 
is some of my users have had data lost somewhere in this process.  The 
web site is www.thewishzone.com.  It is a wish list site and the data 
that seems to be getting lost is the price of an item a user adds to 
their wish list.  I can't seem to duplicate it here.  However one user 
did have it happen twice in a short time period.  They enter a valid 
price and after the record posts the price goes to zero.  Any ideas?
pretty hard to tell with this information. What you might want to do, is 
to call the error_log() function with the insert query that is being 
executed. That way you will have a record of each query that has been 
executed. (if you have a software that can analyse your mysql binary 
log, it could serve the same purpose). You could then look at these 
queries to see if there is anything suspicious.

You could also have a bit of code that tests the value of the price 
variable in each page and mail you all the env settings if price happens 
to be zero that way you would have a chance of reproducing the problem.

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

--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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